Skip to content

Commit

Permalink
Apply consistent formatting
Browse files Browse the repository at this point in the history
Signed-off-by: Donald Raab <[email protected]>
  • Loading branch information
donraab committed Oct 10, 2023
1 parent 37311f0 commit 1c0f5f7
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

public class CoffeeShopOrder
{

private final String customerName;
private final List<Item> orderItems;

Expand Down Expand Up @@ -66,17 +65,17 @@ public String generateReceiptForFoodItems()
{
if (item instanceof Donut(DonutType donutType))
{
receiptItems.add("Donut: "+ donutType + " $" + item.getPrice());
receiptItems.add("Donut: " + donutType + " $" + item.getPrice());
total += item.getPrice();
}
else if (item instanceof Bagel(BagelType bagelType, SpreadType spreadType, boolean toasted))
{
receiptItems.add("Bagel: "+ bagelType +" $" + item.getPrice());
receiptItems.add("Bagel: " + bagelType + " $" + item.getPrice());
total += item.getPrice();
}
else if (item instanceof Cookie(CookieType cookieType, boolean warmed))
{
receiptItems.add("Cookie: " + cookieType +" $" + item.getPrice());
receiptItems.add("Cookie: " + cookieType + " $" + item.getPrice());
total += item.getPrice();
}
}
Expand Down Expand Up @@ -105,7 +104,9 @@ public List<String> getFoodItemsForOrder()
case Bagel bagel -> foodItems.add(bagel.bagelType() + " bagel with " + bagel.spreadType());
case Cookie cookie -> foodItems.add(cookie.cookieType() + " cookie");
case Donut donut -> foodItems.add(donut.donutType() + " donut");
default -> {}
default ->
{
}
}
}
return foodItems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public CoffeeShopOrder(String customerName, List<Item> orderItems)
*
* @see <a href="https://openjdk.org/jeps/440">...</a>
*/
public String generateReceiptForFoodItems() {
public String generateReceiptForFoodItems()
{
// TODO: Implement the receipt generation logic here.
// Hint: look at the Java 8 implementation in the jdk8 module,
// and the link above to see how record patterns can be utilized here
Expand All @@ -77,7 +78,8 @@ public String generateReceiptForFoodItems() {
*
* @see <a href="https://openjdk.org/jeps/441">...</a>
*/
public List<String> getFoodItemsForOrder() {
public List<String> getFoodItemsForOrder()
{
// TODO: implement method
// Hint: look at the Java 8 implementation in the jdk8 module,
// and the link above to see how pattern matching for switch can be utilized here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
* Modify the following class to permit only the classes
* Latte, Macchiato, and Americano, while excluding Tea.
* Make Americano, Macchiato "non-sealed" class and Latte as a "final" class
*
* <p>
* NOTE: This class hierarchy shows the usage of sealed classes
*
* @see <a href="https://openjdk.org/jeps/395">...</a>
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

package bnymellon.codekatas.coffeeshopkata.food;

public record Cookie(CookieType cookieType, boolean warmed) implements BakeryItem {

public record Cookie(CookieType cookieType, boolean warmed) implements BakeryItem
{
@Override
public double getPrice() {
public double getPrice()
{
return 1.25;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

package bnymellon.codekatas.coffeeshopkata.food;

public record Donut(DonutType donutType) implements BakeryItem {

public record Donut(DonutType donutType) implements BakeryItem
{
@Override
public double getPrice() {
public double getPrice()
{
return 1.75;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,21 @@ public String generateReceiptForFoodItems()
{
Donut donut = (Donut) item;
DonutType donutType = donut.getDonutType();
receiptItems.add("Donut: "+ donutType + " $" + item.getPrice());
receiptItems.add("Donut: " + donutType + " $" + item.getPrice());
total += item.getPrice();
}
else if (item instanceof Bagel)
{
Bagel bagel = (Bagel) item;
BagelType bagelType = bagel.getBagelType();
receiptItems.add("Bagel: "+ bagelType +" $" + item.getPrice());
receiptItems.add("Bagel: " + bagelType + " $" + item.getPrice());
total += item.getPrice();
}
else if (item instanceof Cookie)
{
Cookie cookie = (Cookie) item;
CookieType cookieType = cookie.getCookieType();
receiptItems.add("Cookie: " + cookieType +" $" + item.getPrice());
receiptItems.add("Cookie: " + cookieType + " $" + item.getPrice());
total += item.getPrice();
}
}
Expand Down Expand Up @@ -121,7 +121,8 @@ else if (item instanceof Donut)
Donut donut = (Donut) item;
foodItems.add(donut.getDonutType() + " donut");
}
else {
else
{
// it is a beverage, do nothing!
}
}
Expand Down Expand Up @@ -153,4 +154,4 @@ public List<String> getDrinksForOrder()

return drinkItems;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ public Tea(TeaType teaType)
{
this.teaType = teaType;
}

@Override
public String toString()
{
return teaType + " " + "Tea";
}

@Override
public double getPrice()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ public SpreadType getSpreadType()
@Override
public boolean equals(Object obj)
{
if (obj instanceof Bagel) {
if (obj instanceof Bagel)
{
Bagel bagel = (Bagel) obj;
return this.isToasted() == bagel.isToasted() && this.getBagelType() == bagel.getBagelType()
&& this.getSpreadType() == bagel.getSpreadType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public CookieType getCookieType()
@Override
public boolean equals(Object obj)
{
if (obj instanceof Cookie) {
if (obj instanceof Cookie)
{
Cookie cookie = (Cookie) obj;
return this.isWarmed() == cookie.isWarmed() && this.getCookieType() == cookie.getCookieType();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public DonutType getDonutType()
@Override
public boolean equals(Object obj)
{
if (obj instanceof Donut) {
if (obj instanceof Donut)
{
Donut donut = (Donut) obj;
return this.getDonutType() == donut.getDonutType();
}
Expand Down

0 comments on commit 1c0f5f7

Please sign in to comment.