Skip to content

Commit 0e5546f

Browse files
author
jjcapparell
committed
chore: spotlessApply edits
1 parent 463923b commit 0e5546f

File tree

3 files changed

+33
-31
lines changed

3 files changed

+33
-31
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.codedifferently.lesson16.Lunch;
22

33
public class InvalidCalorieException extends Exception {
4-
public InvalidCalorieException(String message) {
5-
super(message);
6-
}
4+
public InvalidCalorieException(String message) {
5+
super(message);
6+
}
77
}

lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/Lunch/Lunch.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ public enum LunchType {
1919
private final ArrayList<String> drinks; // Collection type (ArrayList)
2020

2121
// Constructor
22-
public Lunch(String mainDish, String sideDish, int calories, LunchType lunchType) throws InvalidCalorieException {
22+
public Lunch(String mainDish, String sideDish, int calories, LunchType lunchType)
23+
throws InvalidCalorieException {
2324
if (calories <= 0) {
24-
throw new InvalidCalorieException("Calories cannot be zero or negative.");
25+
throw new InvalidCalorieException("Calories cannot be zero or negative.");
2526
}
2627
this.mainDish = mainDish;
2728
this.sideDish = sideDish;

lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/LunchTest/LunchTest.java

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ public ArrayList<String> getDrinks() {
6060
}
6161

6262
@Test
63-
public void testLunchType() throws InvalidCalorieException {
64-
lunch = new Lunch("Tofu Stir Fry", "Brown Rice", 350, Lunch.LunchType.VEGAN);
65-
assertEquals(Lunch.LunchType.VEGAN, lunch.getLunchType());
66-
}
63+
public void testLunchType() throws InvalidCalorieException {
64+
lunch = new Lunch("Tofu Stir Fry", "Brown Rice", 350, Lunch.LunchType.VEGAN);
65+
assertEquals(Lunch.LunchType.VEGAN, lunch.getLunchType());
66+
}
6767

68-
@Test
69-
public void testAddMultipleDrinks() {
68+
@Test
69+
public void testAddMultipleDrinks() {
7070
lunch.addDrink("Soda");
7171
lunch.addDrink("Juice");
7272
lunch.addDrink("Coffee");
@@ -78,32 +78,33 @@ public void testAddMultipleDrinks() {
7878

7979
assertEquals(expectedDrinks.size(), lunch.getDrinks().size());
8080
assertTrue(lunch.getDrinks().containsAll(expectedDrinks));
81-
}
81+
}
8282

83-
@Test
84-
public void testHighCalories() throws InvalidCalorieException {
83+
@Test
84+
public void testHighCalories() throws InvalidCalorieException {
8585
lunch = new Lunch("Double Cheeseburger", "Loaded Fries", 2000, Lunch.LunchType.NON_VEGETARIAN);
8686
assertEquals(2000, lunch.getCalories());
87-
}
87+
}
8888

89-
@Test
90-
public void testEmptyMainDish() throws InvalidCalorieException {
89+
@Test
90+
public void testEmptyMainDish() throws InvalidCalorieException {
9191
lunch = new Lunch("", "Salad", 300, Lunch.LunchType.VEGETARIAN);
9292
assertEquals("", lunch.getMainDish());
93-
}
93+
}
9494

95-
// Expected to fail with exception message: Calories cannot be zero or negative
96-
@Test
97-
public void testZeroCalories() throws InvalidCalorieException {
98-
lunch = new Lunch("Fruit Salad", "Yogurt", 0, Lunch.LunchType.VEGAN);
99-
assertEquals("Fruit Salad", lunch.getMainDish());
100-
assertEquals(0, lunch.getCalories());
101-
}
95+
// Expected to fail with exception message: Calories cannot be zero or negative
96+
@Test
97+
public void testZeroCalories() throws InvalidCalorieException {
98+
lunch = new Lunch("Fruit Salad", "Yogurt", 0, Lunch.LunchType.VEGAN);
99+
assertEquals("Fruit Salad", lunch.getMainDish());
100+
assertEquals(0, lunch.getCalories());
101+
}
102102

103-
// Expected to fail with exception message: Calories cannot be zero or negative
103+
// Expected to fail with exception message: Calories cannot be zero or negative
104104
@Test
105-
public void testNegativeCaloriesThrowsException() throws InvalidCalorieException {
106-
impossibleLunch = new Lunch("Grilled Chicken", "Caesar Salad", -100, Lunch.LunchType.NON_VEGETARIAN);
107-
assertEquals(-100, lunch.getCalories());
108-
}
109-
}
105+
public void testNegativeCaloriesThrowsException() throws InvalidCalorieException {
106+
impossibleLunch =
107+
new Lunch("Grilled Chicken", "Caesar Salad", -100, Lunch.LunchType.NON_VEGETARIAN);
108+
assertEquals(-100, lunch.getCalories());
109+
}
110+
}

0 commit comments

Comments
 (0)