forked from PacktPublishing/Java-Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMelon.java
More file actions
35 lines (26 loc) · 643 Bytes
/
Melon.java
File metadata and controls
35 lines (26 loc) · 643 Bytes
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
package modern.challenge;
public class Melon {
private final String type;
private int weight;
public Melon(String type, int weight) {
this.type = type;
this.weight = weight;
}
public static int growing100g(Melon melon) {
melon.setWeight(melon.getWeight() + 100);
return melon.getWeight();
}
public String getType() {
return type;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
@Override
public String toString() {
return type + "(" + weight + "g)";
}
}