-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResumeGenerator.java
More file actions
91 lines (76 loc) · 3.02 KB
/
ResumeGenerator.java
File metadata and controls
91 lines (76 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package Architecture;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
// Класс резюме
class Resume implements Cloneable {
private String name;
private String position;
private List<String> skills;
// Имитация дорогой операции
public Resume(String name, String position, List<String> skills) throws InterruptedException {
this.name = name;
this.position = position;
this.skills = new ArrayList<>(skills);
System.out.println("Инициализация шаблона...");
TimeUnit.MILLISECONDS.sleep(1000); // Имитация долгой операции
}
@Override
protected Resume clone() {
try {
Resume cloned = (Resume) super.clone();
// Глубокое копирование списка навыков
cloned.skills = new ArrayList<>(this.skills);
return cloned;
} catch (CloneNotSupportedException e) {
throw new AssertionError(e);
}
}
public void setName(String name) {
this.name = name;
}
public void setPosition(String position) {
this.position = position;
}
@Override
public String toString() {
return "Резюме:\n" +
"Имя: " + name + "\n" +
"Позиция: " + position + "\n" +
"Навыки: " + String.join(", ", skills) + "\n";
}
}
public class ResumeGenerator {
public static void main(String[] args) throws InterruptedException {
// Создаем эталонное резюме
List<String> skills = List.of(
"Java",
"Spring",
"SQL",
"Git",
"REST"
);
System.out.println("Создание эталонного шаблона...");
Resume seniorTemplate = new Resume(
"Иван Петров",
"Senior Java Developer",
skills
);
// Клонируем шаблон три раза
System.out.println("\nКлонирование шаблона...");
Resume juniorResume = seniorTemplate.clone();
juniorResume.setName("Петр Иванов");
juniorResume.setPosition("Junior Java Developer");
Resume middleResume = seniorTemplate.clone();
middleResume.setName("Анна Сидорова");
middleResume.setPosition("Middle Java Developer");
Resume seniorResume = seniorTemplate.clone();
seniorResume.setName("Мария Иванова");
seniorResume.setPosition("Senior Java Developer");
// Выводим результаты
System.out.println("\nРезультаты клонирования:");
System.out.println(juniorResume);
System.out.println(middleResume);
System.out.println(seniorResume);
}
}