-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDish.java
More file actions
68 lines (53 loc) · 2.45 KB
/
Dish.java
File metadata and controls
68 lines (53 loc) · 2.45 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
public class Dish {
private int Cost; //double costInCents
private String Name;
private boolean Recommended;
public void printSummary(){
System.out.printf("%d %s %s %n", Cost, Name, Recommended);
};
public void changeDish(String Name) {
if (Name.isEmpty()) {
this.Name ="";
} else {
this.Name = Name;
}
}
public void changeDish(int Cost) {
this.Cost = Cost;
}
public void changeDish(boolean Recommended) {
this.Recommended = Recommended;
}
}
// public static void main(String[] args) {
// Dish dish = new Dish();
// dish.Cost = 1;
// dish.Name = "Day in the Life";
// dish.Recommended = true;
//
// }
// }
/*OOP SHORT ASSIGNMENT #1 --
Include an integer property called “costInCents”
Include a string property called “nameOfDish”
Include a boolean property called “wouldRecommend”
Include a method called “printSummary” with a void return type
this method will use a single printf method to print out the values of each of the instance properties in the following format:
Cost: COST_IN_CENTS_HERE
Name: NAME_OF_DISH_HERE
Recommended: BOOLEAN_VALUE_OF_WOULD_RECOMMEND_HERE
Create another class called DishTest
Add a main method and inside the method...
1) instantiate a Dish object and assign to a variable called dish1
2) assign creative values for each of the properties
3) test the printSummary() method by invoking it and checking if all instance values are correctly printed
*/
/* SHORT ASSIGNMENT #2 --
Create a class of static members (variables and methods) called DishTools
- AVERAGE_COST_OF_DISH_IN_CENTS - an integer constant set to 1300
- shoutDishName() - that takes in a Dish object and prints out the name in all caps
- analyzeDishCost() - that takes in a Dish object and will print out either “More expensive than average” or “Less expensive than average”, depending on the value of the dish costInCents compared to AVERAGE_COST_OF_DISH_IN_CENTS
- flipRecommendation() - that takes in a Dish object and reverses the wouldRecommend boolean value
Try out the DishTools methods with Dish objects in the DishTest main method
BONUS - add some static methods to the Dish class that compares two dishes in some way
*/