-
-
Save AleksandrPikalo/c6879808f04fe9d36cc1ac4231b45537 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package menu; | |
public class MenuRunner { | |
public static void main(String[] args) { | |
Menu menu1 = new Menu("First"); | |
Menu menu2 = new Menu("Second"); | |
Dish borch = new Dish("Borch", "Hot", 35); | |
Dish sup = new Dish("Sup", "Hot", 30); | |
Dish kharcho = new Dish("Kharcho", "Hot", 25); | |
Dish potato = new Dish("Potato", "Hot", 20); | |
Dish meat = new Dish("Meat", "Hot", 45); | |
Dish cake = new Dish("Cake", "Cold", 35); | |
menu1.addDish(borch); | |
menu1.addDish(sup); | |
menu1.addDish(kharcho); | |
menu2.addDish(potato); | |
menu2.addDish(meat); | |
menu2.addDish(cake); | |
System.out.println("The cheapest dish is: " + menu1.getCheapestDish()); | |
System.out.println("The cheapest dish is: " + menu2.getCheapestDish()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package menu; | |
public class Dish { | |
private final String name; | |
private final String description; | |
private final long price; | |
@Override | |
public String toString() { | |
return "Dish{" + | |
"price=" + price + | |
'}'; | |
} | |
public String getDescription() { | |
return description; | |
} | |
public long getPrice() { | |
return price; | |
} | |
public String getName() { | |
return name; | |
} | |
public Dish(String name, String description, long price) { | |
this.name = name; | |
this.description = description; | |
this.price = price; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment