Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Pasta extends MenuItem {
- private boolean isSalad;
- private String[] ingredients;
- public Pasta(String name, double price, boolean isSalad, String[] ingredients) {
- super(name, price);
- this.isSalad = isSalad;
- this.ingredients = ingredients;
- }
- @Override
- public double getPrice() {
- double price = super.getPrice();
- for (String ingredient : ingredients) {
- if (ingredient.toLowerCase().equals("nuts")) {
- price += 20;
- break;
- }
- }
- return price;
- }
- @Override
- public boolean isServedHot() {
- return !isSalad;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment