Skip to content

Commit 63fa3ba

Browse files
authored
Updating lasagna and wizards-and-warriors-2 to use directly invokemethod (#2735)
[no important files changed]
1 parent b8506ad commit 63fa3ba

File tree

2 files changed

+11
-53
lines changed

2 files changed

+11
-53
lines changed

exercises/concept/lasagna/src/test/java/utils/Lasagna.java

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,18 @@ public String getTargetClassName() {
88
}
99

1010
public int expectedMinutesInOven() {
11-
try {
12-
return invokeMethod("expectedMinutesInOven", new Class[]{});
13-
} catch (Exception e) {
14-
throw new UnsupportedOperationException("Please implement the expectedMinutesInOven() method");
15-
}
11+
return invokeMethod("expectedMinutesInOven", new Class[]{});
1612
}
1713

1814
public int remainingMinutesInOven(int actualMinutes) {
19-
try {
20-
return invokeMethod("remainingMinutesInOven", new Class[]{int.class}, actualMinutes);
21-
} catch (Exception e) {
22-
throw new UnsupportedOperationException("Please implement the remainingMinutesInOven(int) method");
23-
}
15+
return invokeMethod("remainingMinutesInOven", new Class[]{int.class}, actualMinutes);
2416
}
2517

2618
public int preparationTimeInMinutes(int amountLayers) {
27-
try {
28-
return invokeMethod("preparationTimeInMinutes", new Class[]{int.class}, amountLayers);
29-
} catch (Exception e) {
30-
throw new UnsupportedOperationException("Please implement the preparationTimeInMinutes(int) method");
31-
}
19+
return invokeMethod("preparationTimeInMinutes", new Class[]{int.class}, amountLayers);
3220
}
3321

3422
public int totalTimeInMinutes(int amountLayers, int actualMinutes) {
35-
try {
36-
return invokeMethod("totalTimeInMinutes", new Class[]{int.class, int.class}, amountLayers, actualMinutes);
37-
} catch (Exception e) {
38-
throw new UnsupportedOperationException("Please implement the totalTimeInMinutes(int, int) method");
39-
}
23+
return invokeMethod("totalTimeInMinutes", new Class[]{int.class, int.class}, amountLayers, actualMinutes);
4024
}
4125
}
Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* This is a helper class to be able to run the tests for this exercise.
33
* The tests are located in the {@link GameMasterTest} class.
4+
*
45
* @see GameMasterTest
56
*/
67
public class GameMasterProxy extends ReflectionProxy {
@@ -11,50 +12,23 @@ public String getTargetClassName() {
1112
}
1213

1314
public String describe(Character character) {
14-
try {
15-
return invokeMethod("describe", new Class[]{Character.class}, character);
16-
} catch (Exception e) {
17-
throw new UnsupportedOperationException("Please implement the 'describe(Character character)' " +
18-
"method");
19-
}
15+
return invokeMethod("describe", new Class[] { Character.class }, character);
2016
}
2117

2218
public String describe(Destination character) {
23-
try {
24-
return invokeMethod("describe", new Class[]{Destination.class}, character);
25-
} catch (Exception e) {
26-
throw new UnsupportedOperationException("Please implement the 'describe(Destination destination)' " +
27-
"method");
28-
}
19+
return invokeMethod("describe", new Class[] { Destination.class }, character);
2920
}
3021

3122
public String describe(TravelMethod character) {
32-
try {
33-
return invokeMethod("describe", new Class[]{TravelMethod.class}, character);
34-
} catch (Exception e) {
35-
throw new UnsupportedOperationException("Please implement the 'describe(TravelMethod travelMethod)' " +
36-
"method");
37-
}
23+
return invokeMethod("describe", new Class[] { TravelMethod.class }, character);
3824
}
3925

4026
public String describe(Character character, Destination destination, TravelMethod travelMethod) {
41-
try {
42-
return invokeMethod("describe", new Class[]{Character.class, Destination.class, TravelMethod.class},
43-
character, destination, travelMethod);
44-
} catch (Exception e) {
45-
throw new UnsupportedOperationException("Please implement the 'describe(Character character, Destination " +
46-
"destination, TravelMethod travelMethod)' method");
47-
}
27+
return invokeMethod("describe", new Class[] { Character.class, Destination.class, TravelMethod.class },
28+
character, destination, travelMethod);
4829
}
4930

5031
public String describe(Character character, Destination destination) {
51-
try {
52-
return invokeMethod("describe", new Class[]{Character.class, Destination.class},
53-
character, destination);
54-
} catch (Exception e) {
55-
throw new UnsupportedOperationException("Please implement the 'describe(Character character, Destination " +
56-
"destination)' method");
57-
}
32+
return invokeMethod("describe", new Class[] { Character.class, Destination.class }, character, destination);
5833
}
59-
6034
}

0 commit comments

Comments
 (0)