-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1.java
More file actions
83 lines (67 loc) · 1.91 KB
/
1.java
File metadata and controls
83 lines (67 loc) · 1.91 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
import java.text.MessageFormat;
public class Worker {
// Поля класса | объекты
private String fullName; // Ф.И.О.
private String position; // Должность
private String email; // емаил
private String phone; // Телефон
private int salary; // Зарплата
private int age; // Возраст
// Конструктор
public Worker(String fullName, String position, String email, String phone, int salary, int age) {
// this. обращаемся к переменным этого же класса.
// this. Стучимся к самому классу Worker и его поле fullName
this.fullName = fullName;
this.position = position;
this.email = email;
this.phone = phone;
this.salary = salary;
this.age = age;
}
// это метод
public String workerInfo() {
String pattern = "fullName: {0}, position: {1}, email: {2}, phone: {3}, salary: {4}, age: {5}";
return MessageFormat.format(pattern, this.fullName, this.position, this.email, this.phone, this.salary, this.age);
}
public String getFullName() {
return fullName;
}
// Установить
public void setFullName(String fullName) {
this.fullName = fullName;
}
// Получить
public String getPosition() {
return position;
}
// Установить
public void setPosition(String position) {
this.position = position;
}
// и т д
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
// А если сделать private String getPhone - то вообще смысла от геттера нету.
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
// this. Стучимся к самому классу Worker и его поле phone
this.phone = phone;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}