Skip to content

Commit a1fe80b

Browse files
author
Tanechka
committed
Lesson07 enum
1 parent 63674b7 commit a1fe80b

2 files changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package ru.javawebinar.basejava;
2+
3+
import ru.javawebinar.basejava.model.SectionType;
4+
5+
public class TestSingleton {
6+
private static TestSingleton instance;
7+
8+
public static TestSingleton getInstance() {
9+
if (instance == null) {
10+
instance = new TestSingleton();
11+
}
12+
return instance;
13+
}
14+
15+
private TestSingleton() {
16+
}
17+
18+
public static void main(String[] args) {
19+
TestSingleton.getInstance().toString();
20+
Singleton instance = Singleton.valueOf("INSTANCE");
21+
System.out.println(instance.ordinal());
22+
23+
for (SectionType type : SectionType.values()) {
24+
System.out.println(type.getTitle());
25+
}
26+
}
27+
28+
public enum Singleton {
29+
INSTANCE
30+
}
31+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package ru.javawebinar.basejava.model;
2+
3+
public enum SectionType {
4+
PERSONAL("Личные качества"),
5+
OBJECTIVE("Позиция"),
6+
ACHIEVEMENT("Достижения"),
7+
QUALIFICATIONS("Квалификация"),
8+
EXPERIENCE("Опыт работы"),
9+
EDUCATION("Образование");
10+
11+
private String title;
12+
13+
SectionType(String title) {
14+
this.title = title;
15+
}
16+
17+
public String getTitle() {
18+
return title;
19+
}
20+
}
21+

0 commit comments

Comments
 (0)