-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFoodItem.java
More file actions
95 lines (75 loc) · 2.22 KB
/
FoodItem.java
File metadata and controls
95 lines (75 loc) · 2.22 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
* Author: Ryan Smith
* Date: 3/13/2026
* Section: CSC 311-002
*/
public class FoodItem extends StoreItem {
//number of calories per item unit
private int calories;
//expiration date of item in format YYYYMMDD
private double expirationDate;
//determine if the food item has seeds (vegetable vs fruit)
private boolean hasSeeds;
// What color is the fruit?
private String color;
/**
* Initialize new instance of food item
* @param itemID
* @param price
* @param quantity
* @param calories
* @param expirationDate
* @param hasSeeds
*/
public FoodItem(int itemID, String name, double price, int quantity, int calories,
double expirationDate, String color, boolean hasSeeds) {
//call constructor of StoreItem
super(itemID, name, price, quantity);
this.calories = calories;
this.expirationDate = expirationDate;
this.hasSeeds = hasSeeds;
this.color = color;
}
//Accessors
/**
* Return the calories attribute
* @return calories
*/
public int getCalories() {return this.calories;}
/**
* Return expiration date attribute
* @return expirationDate
*/
public double getExpirationDate() {return this.expirationDate;}
/**
* Return if the item has seeds or not
* @return hasSeeds
*/
public boolean getHasSeeds() {return this.hasSeeds;}
/**
* Accessor for color
* @return color
*/
public String getColor() {return this.color;}
//Mutators
/**
* Set the number of calories for the food item
* @param calories
*/
public void setCalories(int calories) {this.calories = calories;}
/**
* Set the expiration date of the food item (format YYYYMMDD)
* @param expirationDate
*/
public void setExpirationDate(int expirationDate) {this.expirationDate = expirationDate;}
/**
* Set the boolean attribute to determine if the food item has seeds
* @param hasSeeds
*/
public void setHasSeeds(boolean hasSeeds) {this.hasSeeds = hasSeeds;}
/**
* Mutator for color
* @param color
*/
public void setColor(String color) {this.color = color;}
}