-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFruitSnack.java
More file actions
40 lines (30 loc) · 787 Bytes
/
FruitSnack.java
File metadata and controls
40 lines (30 loc) · 787 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
36
37
38
39
40
/*
* Matthew Homan
* Assignment 2: Inheritance and Encapsulation
* April 11, 2023
* CMIS 242 7382
* Spring 2023
*
* This program allows a user to order a salty or fruit snack and choose from additional options.
* It then calculates the price and displays the order.
*
*/
public class FruitSnack extends Snack{
private boolean hasCitrus;
public FruitSnack(String id, String size, boolean hasCitrus) {
super(id, size);
this.hasCitrus = hasCitrus;
if(hasCitrus == true) {
setPrice(getPrice() + CITRUS);
}
}
public boolean isHasCitrus() {
return hasCitrus;
}
public void setHasCitrus(boolean hasCitrus) {
this.hasCitrus = hasCitrus;
}
public String toString() {
return "You have chosen snack type = Fruit Snack, of " + super.toString();
}
}