-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBouquet.java
40 lines (32 loc) · 967 Bytes
/
Bouquet.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
public class Bouquet extends Product {
public int numOfRoses;
public int numOfTulips;
public Bouquet(String name, double price, int roses, int tulips) throws Exception {
super(name, price);
// Check if enough flowers in inventory
if (Inventory.getRoses() < roses) {
System.out.println("Not enough roses in stock to make this bucket.");
throw new Exception();
}
if (Inventory.getTulips() < tulips) {
System.out.println("Not enough tulips in stock to make this bucket.");
throw new Exception();
}
// Reduce flowers in inventory
for (int i = 0; i < roses; i++) {
Inventory.removeFlower("rose");
}
for (int i = 0; i < tulips; i++) {
Inventory.removeFlower("tulip");
}
this.numOfRoses = roses;
this.numOfTulips = tulips;
}
// ACCESSORS
public int getNumOfRoses() {
return this.numOfRoses;
}
public int getNumOfTulips() {
return this.numOfTulips;
}
}