Skip to content

Commit 1b785e7

Browse files
Evan PhilakhongEvan Philakhong
authored andcommitted
refactor: adds JavaDoc style
1 parent c0e39af commit 1b785e7

File tree

1 file changed

+44
-5
lines changed
  • lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/evanphilakhong

1 file changed

+44
-5
lines changed

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

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ public class Formula1Car {
1515
private TyreCompound currTyre;
1616
private boolean drs;
1717

18-
// constructors
18+
/**
19+
* Default Constructor for a Formula1Car with no team, empty
20+
* sponsors array, empty driver name, driver number 0, no tyre
21+
* compound, and DRS is disabled by default
22+
*/
1923
public Formula1Car() {
2024
this.team = null;
2125
this.sponsors = new String[0];
@@ -24,7 +28,17 @@ public Formula1Car() {
2428
this.currTyre = null;
2529
this.drs = false;
2630
}
27-
31+
/**
32+
* @param team the tean that this Formula1Car belongs
33+
* @param sponsors array of sponsor names accosicated with this Formula1Car
34+
* @param driverName the name of the driver of this Formula1Car
35+
* @param driverNum the drivers number for the Formula1Car
36+
* @param position drivers current racing position on the grid
37+
* @param currTyre current TyreCompound fitted on this Formula1Car
38+
*
39+
* @see Team
40+
* @see TyreCompound
41+
*/
2842
public Formula1Car(
2943
Team team,
3044
String[] sponsors,
@@ -41,7 +55,14 @@ public Formula1Car(
4155
this.drs = false;
4256
}
4357

44-
// methods
58+
/**
59+
* Displays a header line then,
60+
* Prints a list of sponsors to the console.
61+
*
62+
* @throws NoSponsorsException if there are no sponsors associated with this Formula1Car
63+
*
64+
* @see NoSponsorsException
65+
*/
4566
public void printSponsors() throws NoSponsorsException {
4667
if (sponsors.length == 0) {
4768
throw new NoSponsorsException(team + " has no Sponsors");
@@ -52,15 +73,33 @@ public void printSponsors() throws NoSponsorsException {
5273
}
5374
}
5475
}
55-
76+
/**
77+
* Checks if DRS (Drag Reduction System) is availible to use
78+
* This method determines DRS availibility based on weather or not
79+
* your Formula1Car is in the current track's designated DRS zone.
80+
*
81+
* @return {@code true} if DRS is availible (track has a DRS zone),
82+
* {@code false} otherwise
83+
*
84+
* @see Track#isDrsZone()
85+
*/
5686
public boolean isDrsAvailible() {
5787
if (track.isDrsZone()) {
5888
this.drs = true;
5989
return true;
6090
}
6191
return false;
6292
}
63-
93+
/**
94+
* Checks if we need to switch race strategy to account for the rainy weather
95+
* if the weather is LIGHT_RAIN we change the TyreCompound to INTERMEDIATE
96+
* if the weather is HEAVY_RAIN we change the TyreCompound to WET
97+
*
98+
* @return {@code true} if track.getWeather is LIGHT_RAIN || HEAVY_RAIN
99+
* {@code false} otherwise
100+
*
101+
* @see Track#getWeather()
102+
*/
64103
public boolean rainStrategy() {
65104
if (track.getWeather() == Weather.LIGHT_RAIN) {
66105
this.currTyre = TyreCompound.INTERMEDIATE;

0 commit comments

Comments
 (0)