File tree 4 files changed +47
-0
lines changed
basicSubclassesAdamAndEve
test/java/kyu8/basicSubclassesAdamAndEve 4 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,8 @@ Kata Found realized
34
34
35
35
- [ Basic Mathematical Operations] ( basicMathematicalOperations )
36
36
37
+ - [ Basic subclasses - Adam and Eve] ( basicSubclassesAdamAndEve )
38
+
37
39
- [ Find Nearest square number] ( findNearestSquareNumber )
38
40
39
41
Original file line number Diff line number Diff line change
1
+ package kyu8 .basicSubclassesAdamAndEve ;
2
+
3
+ public class God {
4
+ public static Human [] create () {
5
+ Human Adam = new Man ();
6
+ Human Eve = new Woman ();
7
+ return new Human []{Adam , Eve };
8
+ }
9
+ }
10
+
11
+ class Human {
12
+ public Human () {
13
+ }
14
+ }
15
+
16
+ class Man extends Human {
17
+ public Man () {
18
+ }
19
+ }
20
+
21
+ class Woman extends Man {
22
+ public Woman () {
23
+ }
24
+ }
Original file line number Diff line number Diff line change
1
+ # Basic subclasses - Adam and Eve
2
+
3
+ According to the creation myths of the Abrahamic religions, Adam and Eve were the first Humans to wander the Earth.
4
+
5
+ You have to do God's job. The creation method must return an array of length 2 containing objects (representing Adam and
6
+ Eve). The first object in the array should be an instance of the class ``` Man ``` . The second should be an instance of
7
+ the class ``` Woman ``` . Both objects have to be subclasses of Human. Your job is to implement
8
+ the ``` Human, Man and Woman ``` classes.
Original file line number Diff line number Diff line change
1
+ package kyu8 .basicSubclassesAdamAndEve ;
2
+
3
+ import org .junit .jupiter .api .Test ;
4
+
5
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
6
+
7
+ public class testGod {
8
+ @ Test
9
+ public void makingAdam (){
10
+ Human [] paradise = God .create ();
11
+ assertEquals (true , paradise [0 ] instanceof Man , "Adam is a man" );
12
+ }
13
+ }
You can’t perform that action at this time.
0 commit comments