Skip to content

Commit

Permalink
Add more to README.md, and add JEP links within the kata
Browse files Browse the repository at this point in the history
  • Loading branch information
emilie-robichaud committed Sep 13, 2023
1 parent dafcf9a commit 0edbace
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 6 deletions.
18 changes: 16 additions & 2 deletions coffee-shop-kata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [CoffeeShopTest](src/test/java/bnymellon/codekata/coffeeshopkata/newjavafeatures/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 [`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)!

## 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](src/test/java/bnymellon/codekata/coffeeshopkata/newjavafeatures/CoffeeShopTest.java).
Make all the test cases pass by following the TODOs!
2 changes: 1 addition & 1 deletion coffee-shop-kata/SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
3. To verify that the Java 8 module is set up correctly, run [CoffeeShopTest](/old-java-features/src/test/java/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](/new-java-features/src/test/java/CoffeeShopTest.java) in the new-java-features module - the class should compile but most tests will fail.

### Get started
### Getting started
* Follow the [README](coffee-shop-kata/README.md) for instructions on how to complete the kata.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ public CoffeeShopOrder(String customerName, List<Item> orderItems) {
* 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() {
// 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 @@ -40,10 +43,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() {
// 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 @@ -10,6 +10,7 @@
*
* <p>
* NOTE: This class hierarchy shows the usage of sealed classes
* @see https://openjdk.org/jeps/409
*/

//TODO Convert to Sealed interface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package bnymellon.codekatas.coffeekata.food;

/**
* TODO: convert class to record
* @see https://openjdk.org/jeps/395
*/
public class Bagel implements BakeryItem {
private final BagelType bagelType;
private final SpreadType spreadType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package bnymellon.codekatas.coffeekata.food;

/**
* TODO: convert class to record
* @see https://openjdk.org/jeps/395
*/
public class Cookie implements BakeryItem {
private final CookieType cookieType;
private final boolean warmed;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package bnymellon.codekatas.coffeekata.food;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void testDonutGetters() {

@Test
public void testSealedClasses(){
//TODO Convert Coffee Drink to sealed class
// TODO: Convert CoffeeDrink to sealed class
assertTrue(CoffeeDrink.class.isSealed());
assertFalse(Americano.class.isSealed());
assertFalse(Macchiato.class.isSealed());
Expand All @@ -116,7 +116,7 @@ public void testSealedClasses(){

@Test
public void getDrinkItems() {
//TODO Complete the method getDrinkForOrder() in CoffeeShopOrder to make this pass
// TODO: Complete the method getDrinkForOrder() in CoffeeShopOrder to make this pass
List<String> expected = List.of("HOT Americano: $2.0", "HOT Americano: $3.75", "HOT Americano: $3.75", "MATCHA Tea: $1.5");
assertEquals(expected, coffeeShopOrder.getDrinkForOrder());
}
Expand Down

0 comments on commit 0edbace

Please sign in to comment.