-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSweets.java
More file actions
49 lines (43 loc) · 1.47 KB
/
Sweets.java
File metadata and controls
49 lines (43 loc) · 1.47 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
/**
A subclass of the Ingredient superclass
@version 1.0 2015-03-02
@author Vinoth Maruthalingam
*/
public class Sweets extends Ingredient
{
public double sugarContent; // Instance field specific to Sweets object
public Sweets(String name, String foodGroup, double sugarContent, double mass, String color, int stock)
{
super(name, foodGroup, mass, color, stock);
this.sugarContent = sugarContent;
}
public Sweets(String name, String foodGroup, double sugarContent, double mass, String color, int stock, String[] features)
{
super(name, foodGroup, mass, color, stock, features);
this.sugarContent = sugarContent;
}
public Sweets(String name, String foodGroup, double sugarContent)
{
super(name, foodGroup);
this.sugarContent = sugarContent;
}
public double getSugarContent() // Accessor Method
{
return this.sugarContent;
}
/**
Overrides the toString method in the Ingredient super class since there is more information to display
@param no paramters
@return the String containing the information about the object.
*/
public String toString()
{
return ("Name: " + this.getName() + '\n' +
"Food Group: " + this.getFoodGroup() + '\n' +
"Color: " + this.getColor() + '\n' +
"Mass: " + this.getMass() + '\n' +
"Stock: " + this.getStock() + '\n' +
"Sugar Content: " + this.getSugarContent() + '\n' +
this.displayKeyFeatures());
}
}