Skip to content

Commit

Permalink
Update README, SETUP and add more descriptive TODO comments
Browse files Browse the repository at this point in the history
  • Loading branch information
emilie-robichaud committed Sep 15, 2023
1 parent 050089e commit 99b6ab1
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CoffeeShopOrder(String customerName, List<Item> orderItems)
}

/**
* Print out a list of custom strings for the customer's food items!
* Return a list of custom strings for the customer's food items!
* If the item is a Bagel: Print [bagelType] with [spreadType]
* If the item is a Cookie: Print [cookieType]
* If the item is a Donut: Print [donutType]
Expand Down
22 changes: 18 additions & 4 deletions coffee-shop-kata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Java features while comparing them with older.

The domain for the kata is a Coffee Shop. There are several domain
classes that are shared by all the exercises. These are
[`Items`](src/main/java/bnymellon/codekatas/coffeeshopkata/Item.java),
[`CoffeeShopOrder`](src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java),
[`Items`](jdk8/src/main/java/bnymellon/codekatas/coffeeshopkata/Item.java),
[`CoffeeShopOrder`](jdk8/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java),
[`Beverage`](jdk8/src/main/java/bnymellon/codekatas/coffeeshopkata/beverage/Beverage.java),
[`Tea`](jdk8/src/main/java/bnymellon/codekatas/coffeeshopkata/beverage/Tea.java),
[`CoffeeDrink`](jdk8/src/main/java/bnymellon/codekatas/coffeeshopkata/beverage/CoffeeDrink.java),
Expand All @@ -20,5 +20,19 @@ classes that are shared by all the exercises. These are

![Diagram](CoffeeShopDomain.png)

## Getting Started ##
This kata involves refactoring existing code and implementing missing code! In the [`new-java-features`](./new-java-features) module, you will find a test class called [bnymellon.codekata.coffeeshopkata.CoffeeShopTest](src/test/java/bnymellon/codekata/coffeeshopkata/jdk21/bnymellon.codekata.coffeeshopkata.CoffeeShopTest.java). Each test case contains a TODO that needs to be completed in order to make the code pass. All the code you need to complete is in the [`new-java-features`](./new-java-features) module, with the corresponding solutions in [`coffee-shop-kata-solutions/new-java-features`](../coffee-shop-kata-solutions/new-java-features-solutions). The purpose of the [`old-java-features`](./old-java-features) module is to show you the Java 8 way of solving these problems; there are no TODOs in this module. For technical setup, follow the instructions in [`SETUP.md`](./SETUP.md)!
## Overview ##
This kata involves refactoring existing code and implementing missing code! All the code you need to complete is in
the [`jdk21`](./jdk21) module, with the corresponding solutions
in [`coffee-shop-kata-solutions`](../coffee-shop-kata-solutions). The
purpose of the [`jdk8`](./jdk8) module is to show you the Java 8 way of solving these
problems; there are no TODOs in this module. For technical setup, follow the instructions in [`SETUP.md`](./SETUP.md)!

## Getting started ##
The following Java concepts will be useful in completing the kata:
* [Pattern matching for switch](https://openjdk.org/jeps/441)
* [Records](https://openjdk.org/jeps/395)
* [Record patterns](https://openjdk.org/jeps/440)
* [Sealed classes](https://openjdk.org/jeps/409)

There are failing tests in [CoffeeShopTest](jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java).
Make all the test cases pass by following the TODOs!
24 changes: 11 additions & 13 deletions coffee-shop-kata/SETUP.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
## Setting up the project

### Tooling used
* [JDK 20.0.2+](https://jdk.java.net/20/) installed on your computer
* IntelliJ IDEA 2023.1+ or similar IDE for Java
### Requirements
* [JDK 21](https://jdk.java.net/21/) installed on your computer
* [Maven 3.6.1+](https://maven.apache.org/download.cgi) installed on your computer
* [IntelliJ IDEA 2023.1+](https://www.jetbrains.com/idea/download/?section=windows) or similar IDE for Java

### Initial setup
1. Launch the project in the IDE (can be configured as a maven project, pointing to the root pom.xml)
### Project setup
1. Git clone the entire [code-katas](https://github.com/BNYMellon/CodeKatas) project from GitHub or download the project as a .zip file.
2. Launch the project in the IDE as a maven project. You can find instructions on how to do that [here](https://www.jetbrains.com/idea/guide/tutorials/working-with-maven/importing-a-project/).
3. To verify that the Java 8 module is set up correctly, run [CoffeeShopTest](/jdk8/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java) in the old-java-features module - the class should compile and all tests will pass.
4. To verify that the Java 21 module is set up correctly, run [CoffeeShopTest](/jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java) in the new-java-features module - the class should compile but most tests will fail.

#### Test Java 8 module
1. Verify that the module old-java-features uses JDK 8
2. Run [bnymellon.codekata.coffeeshopkata.CoffeeShopTest](/old-java-features/src/test/java/bnymellon.codekata.coffeeshopkata.CoffeeShopTest.java), all tests should pass
#### Test Java 21 module
1. Verify that the module old-java-features uses JDK 20
2. Run [bnymellon.codekata.coffeeshopkata.CoffeeShopTest](/bnymellon/codekata/coffeeshopkata/newjavafeatures/bnymellon.codekata.coffeeshopkata.CoffeeShopTest.java), most tests should fail
#### Get started
* Make the failing tests in [bnymellon.codekata.coffeeshopkata.CoffeeShopTest](/bnymellon/codekata/coffeeshopkata/newjavafeatures/bnymellon.codekata.coffeeshopkata.CoffeeShopTest.java) pass by following and completing TODOs
### Getting started
* Follow the [README](README.md) for instructions on how to complete the kata.
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,18 @@ public CoffeeShopOrder(String customerName, List<Item> orderItems)
}

/**
* Print out a list of custom strings for the customer's food items!
* Start with, "Order #[orderNumber] for [customerName] includes: "
* If the item is a Bagel: Print [toasted] [bagelType] with [spreadType]
* If the item is a Cookie: Print [warmed] [cookieType]
* Return a list of custom strings for the customer's food items!
* If the item is a Bagel: Print [bagelType] with [spreadType]
* If the item is a Cookie: Print [cookieType]
* If the item is a Donut: Print [donutType]
* <p>
* NOTE: This method show-cases a switch-case pattern matching.
* @see https://openjdk.org/jeps/441
*/
public List<String> getFoodItemsForOrder()
{
public List<String> getFoodItemsForOrder() {
// TODO implement method
// Hint: look at the Java 8 implementation in the old-java-features module,
// and the link above to see how pattern matching for switch can be utilized here
return null;
}

Expand All @@ -54,11 +55,12 @@ public List<String> getFoodItemsForOrder()
* Total: $Total Price
* <p>
* NOTE: The method highlights the usage of a record deconstruction pattern
* @see https://openjdk.org/jeps/440
*/
public String generateReceipt()
{
public String generateReceipt() {
// TODO: Implement the receipt generation logic here.
// Use the instanceof operator and the record pattern to differentiate between different food items.
// Hint: look at the Java 8 implementation in the old-java-features module,
// and the link above to see how record patterns can be utilitzed here
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

import java.util.Objects;

/**
* TODO: convert class to record
* @see https://openjdk.org/jeps/395
*/
public class Bagel implements BakeryItem
{
private final BagelType bagelType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

import java.util.Objects;

/**
* TODO: convert class to record
* @see https://openjdk.org/jeps/395
*/
public class Cookie implements BakeryItem
{
private final CookieType cookieType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public CoffeeShopOrder(String customerName, java.util.List<Item> orderItems)
}

/**
* Print out a list of custom strings for the customer's food items!
* Return a list of custom strings for the customer's food items!
* If the item is a Bagel: Print [bagelType] with [spreadType]
* If the item is a Cookie: Print [cookieType]
* If the item is a Donut: Print [donutType]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

import java.util.Objects;

/**
* TODO: convert class to record
* @see https://openjdk.org/jeps/395
*/
public class Donut implements BakeryItem
{
private final DonutType donutType;
Expand Down

0 comments on commit 99b6ab1

Please sign in to comment.