File tree Expand file tree Collapse file tree 2 files changed +76
-4
lines changed
lesson_16/objects/objects_app/src
main/java/com/codedifferently/lesson16/KimberleeObject
test/java/com/codedifferently/lesson16/KimberleeObjectTest Expand file tree Collapse file tree 2 files changed +76
-4
lines changed Original file line number Diff line number Diff line change 1
- package main . java . com .codedifferently .lesson16 .KimberleeObject ;
1
+ package com .codedifferently .lesson16 .KimberleeObject ;
2
2
3
3
public class HeadPhones {
4
-
4
+ @ SuppressWarnings ("unused" )
5
+ private int volume = 0 ;
6
+
7
+ private boolean isPoweredOn = false ;
8
+ private String HeadPhoneColor = "BLACK" ;
9
+ private boolean isWireless = true ;
10
+ private String brands = "Beats" ;
11
+
12
+ public int getVolume (int volume ) {
13
+ return volume ;
14
+ }
15
+
16
+ public String getHeadPhoneColor () {
17
+ return HeadPhoneColor ;
18
+ }
19
+
20
+ public boolean isPoweredOn () {
21
+ return isPoweredOn ;
22
+ }
23
+
24
+ public boolean isWireless () {
25
+ return isWireless ;
26
+ }
27
+
28
+ public String getBrandsArray () {
29
+ return brands ;
30
+ }
5
31
}
Original file line number Diff line number Diff line change 1
- package test .java .com .codedifferently .lesson16 .KimberleeObjectTest ;
1
+ package com .codedifferently .lesson16 .KimberleeObjectTest ;
2
+
3
+ import static org .junit .jupiter .api .Assertions .*;
4
+ import static org .junit .jupiter .api .Assertions .assertArrayEquals ;
5
+
6
+ import com .codedifferently .lesson16 .KimberleeObject .HeadPhones ;
7
+ import org .junit .jupiter .api .BeforeEach ;
8
+ import org .junit .jupiter .api .Test ;
2
9
3
10
public class HeadPhonesTest {
4
-
11
+
12
+ private HeadPhones headphones ;
13
+
14
+ @ BeforeEach
15
+ public void setUp () {
16
+ headphones = new HeadPhones ();
17
+ }
18
+
19
+ public enum HeadPhoneColor {
20
+ RED ,
21
+ BLUE ,
22
+ ROSEGOLD ,
23
+ PINK ,
24
+ WHITE ,
25
+ BLACK ;
26
+ }
27
+
28
+ public void BrandsArray () {
29
+ String [] brands = new String [5 ];
30
+ brands [0 ] = "Beats" ;
31
+ brands [1 ] = "Sony" ;
32
+ brands [2 ] = "Bose" ;
33
+ brands [3 ] = "SkullCandy" ;
34
+ brands [4 ] = "Juicy" ;
35
+ }
36
+
37
+ @ Test
38
+ public void testDefaultState () {
39
+ assertEquals (0 , headphones .getVolume (0 ), "Volume should be 0 by default." );
40
+ assertEquals ("BLACK" , headphones .getHeadPhoneColor (), "Color should be black by default." );
41
+ assertFalse (headphones .isPoweredOn (), "HeadPhones should be off by default." );
42
+ assertTrue (headphones .isWireless (), "HeadPhones should be wireless by default." );
43
+ assertArrayEquals (new String [] {"Beats" }, new String [] {"Beats" });
44
+ }
45
+ // Arrange
46
+
47
+ // Act
48
+
49
+ // Assert
50
+
5
51
}
You can’t perform that action at this time.
0 commit comments