Skip to content

Commit c40303a

Browse files
committed
chore: debugging
1 parent c3a6ac0 commit c40303a

File tree

2 files changed

+38
-9
lines changed
  • lesson_16/objects/objects_app/src

2 files changed

+38
-9
lines changed

lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/KimberleeObject/HeadPhones.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
import java.util.Arrays;
44

55
public class HeadPhones {
6-
@SuppressWarnings("unused")
7-
private static final Object PREFERRED_BRANDS = null;
86

97
private int volume = 0;
108
private boolean isPoweredOn = false;
119
private HeadPhoneColor headPhoneColor = HeadPhoneColor.BLACK;
1210
private boolean isWireless = true;
1311
private String brands = "Beats";
1412
private boolean isConnectedToBluetooth = false;
13+
private BoostMode currentMode;
14+
private BoostMode[] modes = BoostMode.values();
15+
private int currentModeIndex = 0;
1516

1617
public enum HeadPhoneColor {
1718
RED,
@@ -37,6 +38,10 @@ public enum BoostMode {
3738
TREBLE_BOOST;
3839
}
3940

41+
public void headPhones() {
42+
this.currentMode = BoostMode.BASS_BOOST;
43+
}
44+
4045
public int getVolume(int i) {
4146
return volume;
4247
}
@@ -113,4 +118,13 @@ public void wirelessConnection() throws ConnectionNotFoundException {
113118
throw new ConnectionNotFoundException("Headphones Wireless Connection Not Found.");
114119
}
115120
}
121+
122+
public void nextBoostMode() {
123+
currentModeIndex = (currentModeIndex + 1) % modes.length;
124+
currentMode = modes[currentModeIndex];
125+
}
126+
127+
public BoostMode getCurrentMode() {
128+
return currentMode;
129+
}
116130
}

lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/KimberleeObjectTest/HeadPhonesTest.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ public void testDefaultState() {
2828
assertFalse(headphones.isPoweredOn(), "HeadPhones should be off by default.");
2929
assertTrue(headphones.isWireless(), "HeadPhones should be wireless by default.");
3030
assertArrayEquals(new String[] {"Beats"}, new String[] {"Beats"});
31-
assertEquals(BoostMode.BASS_BOOST, headphones.getCurrentBoostMode(), "BASS_BOOST should be the default setting.");
31+
assertEquals(
32+
BoostMode.BASS_BOOST,
33+
headphones.getCurrentMode(),
34+
"BASS_BOOST should be the default setting.");
3235
}
3336

3437
@Test
@@ -118,17 +121,29 @@ public void testwirelessConnection_connectionNotFound() throws Exception {
118121
.hasMessage("Headphones Wireless Connection Not Found.");
119122
}
120123

121-
@Test
124+
@Test
122125
public void testBoostMode() {
123-
assertEquals(BoostMode.BASS_BOOST, headphones.getCurrentBoostMode(), "BASS_BOOST should be the default setting.");
124-
126+
assertEquals(
127+
BoostMode.BASS_BOOST,
128+
headphones.getCurrentMode(),
129+
"BASS_BOOST should be the default setting.");
130+
125131
headphones.nextBoostMode();
126-
assertEquals(BoostMode.VOCAL_BOOST, headphones.getCurrentBoostMode(), "The next Boost setting should be VOCAL.");
132+
assertEquals(
133+
BoostMode.VOCAL_BOOST,
134+
headphones.getCurrentMode(),
135+
"The next Boost setting should be VOCAL.");
127136

128137
headphones.nextBoostMode();
129-
assertEquals(BoostMode.TREBLE_BOOST, headphones.getCurrentBoostMode(), "The next Boost setting should be TREBLE.");
138+
assertEquals(
139+
BoostMode.TREBLE_BOOST,
140+
headphones.getCurrentMode(),
141+
"The next Boost setting should be TREBLE.");
130142

131143
headphones.nextBoostMode();
132-
assertEquals(BoostMode.BASS_BOOST, headphones.getCurrentBoostMode(), "BoostMode cycle should return to BASS_BOOST.");
144+
assertEquals(
145+
BoostMode.BASS_BOOST,
146+
headphones.getCurrentMode(),
147+
"BoostMode cycle should return to BASS_BOOST.");
133148
}
134149
}

0 commit comments

Comments
 (0)