-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVegetable.java
More file actions
132 lines (109 loc) · 3.42 KB
/
Vegetable.java
File metadata and controls
132 lines (109 loc) · 3.42 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/**
* Author: Ryan Smith
* Date: 3/13/2026
* Section: CSC 311-002
*/
public class Vegetable extends FoodItem {
/** Is the Vehetable a root? */
private boolean isRoot;
/** Is the vegetable a flower? */
private boolean isFlower;
/** Is the vegetable a leaf? */
private boolean isLeaf;
/** Is the vegetable a stem? */
private boolean isStem;
//Constructor
/**
* Initialize new instance of food item
* @param itemID
* @param price
* @param quantity
* @param calories
* @param expirationDate
* @param color
* @param isRoot
* @param isFlower
* @param isLeaf
* @param isStem
*/
public Vegetable(int itemID, String name, double price, int quantity, int calories,
int expirationDate, String color, boolean hasSeeds, boolean isRoot, boolean isFlower, boolean isLeaf, boolean isStem){
//call constructor of food item
super(itemID, name, price, quantity, calories, expirationDate, color, hasSeeds);
this.isRoot = isRoot;
this.isFlower = isFlower;
this.isLeaf = isLeaf;
this.isStem = isStem;
}
//Accessors
/**
* Accessor for isRoot
* @return isRoot
*/
public boolean getIsRoot(){return this.isRoot;}
/**
* Accessor for isFlower
* @return isFlower
*/
public boolean getIsFlower(){return this.isFlower;}
/**
* Accessor for isLeaf
* @return isLeaf
*/
public boolean getIsLeaf(){return this.isLeaf;}
/**
* Accessor for isStem
* @return isStem
*/
public boolean getIsStem(){return this.isStem;}
//Mutators
/**
* Mutator for isRoot
* @param isRoot
*/
public void setIsRoot(boolean isRoot){this.isRoot = isRoot;}
/**
* Mutator for isFlower
* @param isFlower
*/
public void setIsFlower(boolean isFlower){this.isFlower = isFlower;}
/**
* Mutator for isLeaf
* @param isLeaf
*/
public void setIsLeaf(boolean isLeaf){this.isLeaf = isLeaf;}
/**
* Mutator for isStem
* @param isStem
*/
public void setIsStem(boolean isStem){this.isStem = isStem;}
/**
* Creates string to represent a fruit item with attributes:
* itemID
* price
* quantity
* calories
* expirationDate
* color
* hasSeeds
* hasPeel
* isSweet
* shape
*/
@Override
public String toString() {
return String.format("ItemID: %d| Name: %s| Price: %.2f| Quantity: %d| Calories: %d| Expiration Date: %.0f| Color: %s| Has Seeds? %b| Is Root? %b| Is Flower? %b| Is Leaf? %b| Is Stem? %b",
getItemID(), getName(), getPrice(), getQuantity(), getCalories(), getExpirationDate(), getColor(), getHasSeeds(), getIsRoot(), getIsFlower(), getIsLeaf(), getIsStem());
// return "ItemId: " + this.getItemID() +
// "\nPrice: " + this.getPrice() +
// "\nQuantity: " + this.getQuantity() +
// "\nCalories: " + this.getCalories() +
// "\nExpiration Date: " + this.getExpirationDate() +
// "\nColor: " + this.getColor() +
// "\nHas Seeds: " + this.getHasSeeds() +
// "\nIs Root: " + this.getIsRoot() +
// "\nIs Flower: " + this.getIsFlower() +
// "\nIs Leaf: " + this.getIsLeaf() +
// "\nIs Stem: " + this.getIsStem();
}
}