-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFoodItem.java
46 lines (40 loc) · 1.14 KB
/
FoodItem.java
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
/**
* Class to initialize the different food items that would be on the menu.
*/
public class FoodItem implements FoodInterface{
private final String name;
private final double prepTime;
private final FoodTypes type;
public FoodItem(String name, double prepTime, FoodTypes type){
if(name == null || name.isEmpty()) {
throw new IllegalArgumentException("Food name is null. Can't be initialized.");
}
if(prepTime <= 0) {
throw new IllegalArgumentException("Prep time cannot be equal to or less than 0. Can't be initialized");
}
if(type == null) {
throw new IllegalArgumentException("Food type is null. Can't be initialized");
}
this.name = name;
this.prepTime = prepTime;
this.type = type;
}
@Override
public String getName(){
return name;
}
@Override
public double getPrepTime(){
return prepTime;
}
@Override
public FoodTypes getType(){
return type;
}
@Override
public String toString(){
String str = "";
str += "Name: " + name + ", Prep Time: " + prepTime + ", FoodType: " + type;
return str;
}
}