-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSaltySnack.java
More file actions
40 lines (29 loc) · 763 Bytes
/
SaltySnack.java
File metadata and controls
40 lines (29 loc) · 763 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 SaltySnack extends Snack {
private boolean hasNuts;
public SaltySnack(String id, String size, boolean hasNuts) {
super(id, size);
this.hasNuts = hasNuts;
if(hasNuts == true) {
setPrice(getPrice() + NUT);
}
}
public boolean isHasNuts() {
return hasNuts;
}
public void setHasNuts(boolean hasNuts) {
this.hasNuts = hasNuts;
}
public String toString() {
return "You have chosen snack type = Salty Snack, of " + super.toString(); }
}