-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToy.java
More file actions
57 lines (41 loc) · 1.28 KB
/
Copy pathToy.java
File metadata and controls
57 lines (41 loc) · 1.28 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
import java.util.concurrent.atomic.AtomicInteger;
public class Toy {
private static final AtomicInteger COUNTER = new AtomicInteger(0); // id игрушки
private final String name; // название
private final int id;
private int quantity; // количество
private double frequency; // частота выпадения
@Override
public String toString() {
return "Toy{" +
"id=" + id +
", name='" + name + '\'' +
", quantity=" + quantity +
", frequency=" + frequency +
'}';
}
public Toy(String name, int quantity, double frequency) {
this.id = COUNTER.getAndIncrement();
this.name = name;
this.quantity = quantity;
this.frequency = frequency;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public int getQuantity() {
return quantity;
}
public double getFrequency() {
return frequency;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public void setFrequency(double frequency) {
this.frequency = frequency;
}
}