Skip to content

Commit 9e8e798

Browse files
authored
things of God knows no man, but the Spirit of God
For what man knows the things of a man, except the spirit of man which is in him? even so the things of God knows no man, but the Spirit of God. (1Cor 2:11)
1 parent 7f30355 commit 9e8e798

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

  • Multithreading/task25/task2909/Refactoring-3
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
2+
//For what man knows the things of a man, except the spirit of man which is in him? even so the things of God knows no man, but the Spirit of God. (1Cor 2:11)
3+
4+
package com.javarush.task.task29.task2909.human;
5+
6+
import java.util.ArrayList;
7+
import java.util.List;
8+
import java.util.Collections;
9+
10+
public class Human implements Alive {
11+
12+
public static int nextId = 0;
13+
private int id;
14+
protected int age;
15+
protected String name;
16+
17+
private List<Human> children = new ArrayList<>();
18+
19+
protected int[] size;
20+
21+
public static final int FIRST = 1;
22+
public static final int SECOND = 2;
23+
public static final int THIRD = 3;
24+
public static final int FOURTH = 4;
25+
private int bloodGroup;
26+
27+
public Human(String name, int age) {
28+
this.name = name;
29+
this.age = age;
30+
}
31+
32+
public List<Human> getChildren() {
33+
return Collections.unmodifiableList(children);
34+
}
35+
36+
public void live() {}
37+
38+
public void addChild(Human human) {
39+
this.children.add(human);
40+
}
41+
42+
public void removeChild(Human human) {
43+
this.children.remove(human);
44+
}
45+
46+
public void setBloodGroup(int code) {
47+
bloodGroup = code;
48+
}
49+
50+
public int getBloodGroup() {
51+
return bloodGroup;
52+
}
53+
54+
public int getAge() {
55+
return age;
56+
}
57+
58+
public void setAge(int age) {
59+
this.age = age;
60+
}
61+
62+
public String getName() {
63+
return name;
64+
}
65+
66+
public void setName(String name) {
67+
this.name = name;
68+
}
69+
70+
public void printSize() {
71+
System.out.println("Рост: " + size[0] + " Вес: " + size[1]);
72+
}
73+
}
74+
75+
/*
76+
Рефакторинг (3)
77+
3.1. Спуск поля. Спусти поле course в соответствующий класс. Сделай его приватным.
78+
3.2. Спуск метода. Спусти геттер для поля course в соответствующий класс.
79+
3.3. Извлечение интерфейса.
80+
3.3.1. Создай интерфейс Alive (живой) в пакете human.
81+
3.3.2. Интерфейс должен содержать метод жить live().
82+
3.3.3. Добавь интерфейс нужному классу.
83+
3.4. Свертывание иерархии. Избавься от класса Professor.
84+
85+
86+
Требования:
87+
1. Необходимо спустить поле course в нужный класс и сделать его приватным.
88+
2. Необходимо спустить геттер для поля course в нужный класс.
89+
3. Интерфейс Alive должен существовать в пакете human.
90+
4. Интерфейс Alive должен содержать объявление метода жить live().
91+
5. Класс Human должен поддерживать интерфейс Alive.
92+
6. Класс Professor нужно удалить.
93+
*/

0 commit comments

Comments
 (0)