@@ -10,14 +10,21 @@ public enum Model {
10
10
OLED
11
11
}
12
12
13
- // This will be the attributes, or member variables, of the NintendoSwitch class.
14
13
private String serialNumber ;
15
14
private Model model ;
16
15
private boolean isDocked ;
17
16
private double batteryLife ; // This will be in hours.
18
17
private ArrayList <String > installedGames ;
19
18
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
+ */
21
28
public nintendo (
22
29
String serialNumber ,
23
30
Model model ,
@@ -37,22 +44,33 @@ public InvalidBatteryException(String message) {
37
44
}
38
45
}
39
46
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
+ */
41
54
public void checkBatteryStatus () throws InvalidBatteryException {
42
- /** Conditional expression checking battery status */
43
55
if (batteryLife < 0 ) {
44
56
throw new InvalidBatteryException ("Battery life cannot be negative." );
45
57
}
46
58
System .out .println ("Battery life: " + batteryLife + " hours." );
47
59
}
48
60
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
+ */
50
66
public void installGame (String game ) {
51
67
installedGames .add (game );
52
68
System .out .println (game + " has been added to your Nintendo Switch." );
53
69
}
54
70
55
- /** Function 3: Displays all installed games using a loop */
71
+ /**
72
+ * Displays all the games currently installed on the Nintendo Switch.
73
+ */
56
74
public void displayInstalledGames () {
57
75
System .out .println ("Installed games on the Nintendo Switch:" );
58
76
/** Using a normal for loop to iterate over installed games */
@@ -61,7 +79,7 @@ public void displayInstalledGames() {
61
79
}
62
80
}
63
81
64
- /** Getter methods */
82
+ /* Getter methods */
65
83
public String getSerialNumber () {
66
84
return serialNumber ;
67
85
}
0 commit comments