File tree Expand file tree Collapse file tree 2 files changed +45
-3
lines changed
lesson_16/objects/objects_app/src
main/java/com/codedifferently/lesson16/Person Expand file tree Collapse file tree 2 files changed +45
-3
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,11 @@ public void setHeight(double height) {
66
66
67
67
public ArrayList <String > getHairColor () {
68
68
if (hairColor == null ) {
69
- throw new IllegalArgumentException ("No hair color? This person must be bald!" );
69
+ try {
70
+ throw new IllegalArgumentException ("No hair color? This person must be bald!" );
71
+ } catch (IllegalArgumentException e ) {
72
+ hairColor .add ("Bald" );
73
+ }
70
74
}
71
75
return hairColor ;
72
76
}
@@ -97,9 +101,9 @@ public ArrayList<String> getNaturalHairColor() {
97
101
98
102
public String getLifeStatus () {
99
103
if (alive == true ) {
100
- return "alive " ;
104
+ return "Alive " ;
101
105
} else {
102
- return "deceased " ;
106
+ return "Deceased " ;
103
107
}
104
108
}
105
109
Original file line number Diff line number Diff line change
1
+ package com .codedifferently .lesson16 ;
2
+
3
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4
+
5
+ import org .junit .jupiter .api .BeforeEach ;
6
+ import org .junit .jupiter .api .Test ;
7
+
8
+ public class PersonTest {
9
+
10
+ Person person ;
11
+
12
+ // Set up
13
+ @ BeforeEach
14
+ void setUp () {
15
+ person = new person ();
16
+ }
17
+
18
+ @ Test
19
+ // Method being tested
20
+ public void testGet () {
21
+ // Execersise
22
+ int actual = .get ();
23
+
24
+ int expected = ;
25
+ // Assert(Checking the value)
26
+ assertEquals (expected , actual );
27
+ }
28
+
29
+ @ Test
30
+ public void testSet () {
31
+ // Arrange
32
+ int expectedSet = ;
33
+ // Act
34
+ person .set (expectedSet );
35
+ // Assert
36
+ assertEquals (expectedSet , person .get ());
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments