Skip to content

Commit d049059

Browse files
committed
feat: adds rainStrategy() method in Formula1Car Class
1 parent d7120f2 commit d049059

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/evanphilakhong/Formula1Car.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ public boolean isDrsAvailible() {
5656
}
5757

5858
public boolean rainStrategy() {
59-
if (track.isRaining()) {
60-
currTyre.setCurrTyre(TyreCompound.WET);
59+
if (track.getWeather() == Weather.LIGHT_RAIN) {
60+
this.currTyre = TyreCompound.INTERMEDIATE;
61+
return true;
62+
} else if (track.getWeather() == Weather.HEAVY_RAIN) {
63+
this.currTyre = TyreCompound.WET;
64+
return true;
6165
}
66+
return false;
6267
}
6368

6469
public static void main(String[] args) {

lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/evanphilakhong/Track.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class Track {
1111
private int numLaps;
1212
private int trackLengthInKm;
1313
private boolean drsZone;
14-
private boolean raining;
14+
private Weather weather;
1515

1616
public static void main(String[] args) {
1717

0 commit comments

Comments
 (0)