-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDish.java
122 lines (97 loc) · 2.65 KB
/
Dish.java
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package com.salimov.yurii.lesson07.task01;
import javax.persistence.*;
@Entity
@Table(name = "Dishes")
public final class Dish {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "name", nullable = false)
private String name;
@Column(name = "weight", nullable = false)
private double weight;
@Column(name = "price", nullable = false)
private double price;
@Column(name = "discount", nullable = false)
private double discount;
@Column(name = "specification", nullable = false)
private String specification;
public Dish() {
}
public Dish(
final String name,
final double weight,
final double price
) {
this();
this.name = name;
this.weight = weight;
this.price = price;
}
public Dish(
final String name,
final double weight,
final double price,
final double discount
) {
this(name, weight, price);
setDiscount(discount);
}
public Dish(
final String name,
final double weight,
final double price,
final double discount,
final String specification
) {
this(name, weight, price, discount);
this.specification = specification;
}
@Override
public String toString() {
return "Dish id = " + this.id + ":" +
"\n\tname - " + this.name +
"\n\tweight - " + this.weight +
"\n\tprice - " + this.price +
"\n\tdiscount - " + this.discount +
"\n\tspecification - " + this.specification;
}
public void setId(final long id) {
this.id = id;
}
public long getId() {
return this.id;
}
public void setName(final String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public void setWeight(final double weight) {
this.weight = weight;
}
public double getWeight() {
return this.weight;
}
public void setPrice(final double price) {
this.price = price;
}
public double getPrice() {
return this.price;
}
public void setDiscount(final double discount) {
if (discount > 0 && discount < 100) {
this.discount = discount;
}
}
public double getDiscount() {
return this.discount;
}
public void setSpecification(final String specification) {
this.specification = specification;
}
public String getSpecification() {
return this.specification;
}
}