So my questions are geared directly to my homework. Before you ask, yes I've looked at other questions and I have looked at the java docs to try and help me but I only understand so much..
You have become a restaurant mogul. You own several fast food chains. However, you now need to set a standard that all of your fast food chain must follow in order to have your software be uniform across the board. There will be some rules that will be the same for all restaurants.
Create an Abstract Class named Restaurant
Create a function/method that will print the name of the restaurant when called.
Create an abstract function/method named total price
Create an abstract function/method named menu items
Create an abstract function/method name location
Create a Class called McDonalds that extends Restaurant
Implement all abstract methods
Add logic so that the total price method/function will give the total price of the meal including a 6% tax
Add a method that returns a Boolean named hasPlayPlace. Which returns true when this location has a playplace
Create a Constructor that will set the name of the Mcdonalds, location, and hasPlayPlace
This is just a portion of my homework. I'm not looking for anyone to do it for me, just some insight and help in the right direction.
Here's what I've written in only one of the classes:
public class McDonalds extends Restaurant { private String name; private String location; private boolean hasPlayPlace; Scanner input = new Scanner(System.in); public McDonalds (String name, String location, boolean hasPlayPlace) { setName(name); setLocation(location); setHasPlayPlace(hasPlayPlace); } McDonalds location1 = new McDonalds("McDonalds", "Kirkman", false); McDonalds location2 = new McDonalds("McDonalds 2", "International Dr.", true); public String getName() { return name; } public void setName(String name) { this.name = name; } public String getLocation() { return location; } public void setLocation(String location){ this.location = location; } public boolean isHasPlayPlace() { return hasPlayPlace; } public void setHasPlayPlace(boolean hasPlayPlace) { this.hasPlayPlace = hasPlayPlace; } public void totalPrice() { double totalPrice = 0; double tax = 0.06; totalPrice += (totalPrice * tax); } public void menuItems() { double mcChicken = 1; double fries = 1.25; System.out.println("1. Mc Chicken $1"); System.out.println("2. Fries $1.25"); int choice = input.nextInt(); switch (choice){ case 1: mcChicken *= tax; case 2: fries *= tax; } } public void location() { //Don't know what's supposed to go in here. //But I've implemented the method as I was supposed to. } }
So I'm just confused as what goes in each abstract method(totalPrice, menuItems, location) and how I get them to do what they're supposed to do. I've written what I thinks fits into it so far but now I'm stuck.
Here is also another part of the homework:
• Add a method/function that returns a String of what hot sauce you would like..ie hot, fire, mild
• Create a Constructor that will set the name of the TacoBell and location
Here's what I thought worked?
public String TacoBellSauce(String fire, String hot, String mild) { System.out.println("What sauce would you like to have?"); System.out.println("1. Fire"); System.out.println("2. Hot"); System.out.println("3. Mild"); int choice = input.nextInt(); switch(choice) { case 1: return fire; case 2: return hot; case 3: return mild; } return null; }
Can someone point out my mistakes and point me in the right directions?