Skip to content

Commit 8f25b09

Browse files
chore: add proper javadoc
1 parent 6e922e3 commit 8f25b09

File tree

1 file changed

+25
-7
lines changed
  • lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/nintendoswitch

1 file changed

+25
-7
lines changed

lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/nintendoswitch/nintendo.java

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@ public enum Model {
1010
OLED
1111
}
1212

13-
// This will be the attributes, or member variables, of the NintendoSwitch class.
1413
private String serialNumber;
1514
private Model model;
1615
private boolean isDocked;
1716
private double batteryLife; // This will be in hours.
1817
private ArrayList<String> installedGames;
1918

20-
// This will be the constructor for the NintendoSwitch class.
19+
/**
20+
* Constructs a Nintendo Switch object with the specified attributes.
21+
*
22+
* @param serialNumber serial number of the device
23+
* @param model the model type of the Nintendo Switch
24+
* @param isDocked indicates if the device is currently docked
25+
* @param batteryLife current battery life in hours
26+
* @param installedGames list of games currently installed on the device
27+
*/
2128
public nintendo(
2229
String serialNumber,
2330
Model model,
@@ -37,22 +44,33 @@ public InvalidBatteryException(String message) {
3744
}
3845
}
3946

40-
/** Function 1: This will check the battery status. This also has the exception handling. */
47+
48+
/**
49+
* Checks the current battery status of the Nintendo Switch.
50+
* If the battery life is negative, it throws an InvalidBatteryException.
51+
*
52+
* @throws InvalidBatteryException if battery life is less than 0
53+
*/
4154
public void checkBatteryStatus() throws InvalidBatteryException {
42-
/** Conditional expression checking battery status */
4355
if (batteryLife < 0) {
4456
throw new InvalidBatteryException("Battery life cannot be negative.");
4557
}
4658
System.out.println("Battery life: " + batteryLife + " hours.");
4759
}
4860

49-
/** Function 2: Adds a game to the installed games collection */
61+
/**
62+
* Installs a game to the Nintendo Switch.
63+
*
64+
* @param game the name of the game to install
65+
*/
5066
public void installGame(String game) {
5167
installedGames.add(game);
5268
System.out.println(game + " has been added to your Nintendo Switch.");
5369
}
5470

55-
/** Function 3: Displays all installed games using a loop */
71+
/**
72+
* Displays all the games currently installed on the Nintendo Switch.
73+
*/
5674
public void displayInstalledGames() {
5775
System.out.println("Installed games on the Nintendo Switch:");
5876
/** Using a normal for loop to iterate over installed games */
@@ -61,7 +79,7 @@ public void displayInstalledGames() {
6179
}
6280
}
6381

64-
/** Getter methods */
82+
/* Getter methods */
6583
public String getSerialNumber() {
6684
return serialNumber;
6785
}

0 commit comments

Comments
 (0)