10000 Kyu 8 | Basic Subclasses - Adam and Eve · danielex1999/CodeWars-Java@401a0ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 401a0ba

Browse files
committed
Kyu 8 | Basic Subclasses - Adam and Eve
1 parent b9d587f commit 401a0ba

File tree

4 files changed

+47
-0
lines changed

4 files changed

+47
-0
lines changed

src/main/java/kyu8/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Kata Found realized
3434

3535
- [Basic Mathematical Operations](basicMathematicalOperations)
3636

37+
- [Basic subclasses - Adam and Eve](basicSubclassesAdamAndEve)
38+
3739
- [Find Nearest square number](findNearestSquareNumber)
3840

3941

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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+
}

0 commit comments

Comments
 (0)
0