Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Base Class working mainly as Superclass to special burgers of other classes which extend to this base class.
- */
- /**
- * @author Akito
- *
- */
- public class BaseHamburger {
- private char breadRollType;
- private boolean hasMeat;
- private double price;
- /**
- * @param breadRollType
- * @param hasMeat
- * @param price
- *
- * Superconstructor as base construct to children burgers.
- */
- public BaseHamburger(char breadRollType, boolean hasMeat, double price) {
- super();
- this.breadRollType = breadRollType;
- this.hasMeat = hasMeat;
- this.price = price;
- }
- private String ingredient;
- /**
- * @param ingredient the ingredient to set
- * Setting ingredient and calling the addition of the chosen ingredient.
- */
- public void setIngredient(String ingredient) {
- this.ingredient = ingredient;
- if (ingredient.replace("s", "").toLowerCase().equals("tomato") || ingredient.replace("s", "").toLowerCase().equals("lettuce") || ingredient.replace("s", "").toLowerCase().equals("pickle")) {
- System.out.println(ingredient + " added!");
- addIngredient(ingredient);
- }
- else
- System.out.println("Adding ingredient failed. Please select one of the correct ingredients!");
- }
- /*
- * Actually adding ingredient to burger and increasing total price on order.
- * Called by ingredient Setter.
- */
- private void addIngredient(String ingredient) {
- switch (ingredient.replace("s", "").toLowerCase()) {
- case "tomato":
- System.out.println("Added " + ingredient);
- break;
- case "lettuce":
- System.out.println("Added " + ingredient);
- break;
- case "pickle":
- System.out.println("Added " + ingredient);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement