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
28 lines (21 loc) · 615 Bytes
/
Copy pathMelon.java
File metadata and controls
28 lines (21 loc) · 615 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
package modern.challenge;
import java.util.Collections;
import java.util.List;
public class Melon {
private String type;
private int weight;
public Melon() {
}
public Melon(String type, int weight) {
this.type = type;
this.weight = weight;
}
public List<Melon> cultivate(String type, Seed seed, int noOfSeeds) {
System.out.println("The cultivate() method was invoked ...");
return Collections.nCopies(noOfSeeds, new Melon("Gac", 5));
}
@Override
public String toString() {
return type + "(" + weight + "g)";
}
}