beginner programmer - Abstract Concept Assignment - few confusions
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:
Code :
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?
Code :
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?
Re: beginner programmer - Abstract Concept Assignment - few confusions
Quote:
Here's what I thought worked?
If you are getting errors, please copy the full text and paste it here.
Re: beginner programmer - Abstract Concept Assignment - few confusions
Quote:
Originally Posted by
Norm
If you are getting errors, please copy the full text and paste it here.
No errors with the second part. Just don't know if I'm doing it correctly according to the assignment.
Re: beginner programmer - Abstract Concept Assignment - few confusions
Bump to anyone who can answer?
Re: beginner programmer - Abstract Concept Assignment - few confusions
willing to make a paypal donation to anyone who can help me out...
Re: beginner programmer - Abstract Concept Assignment - few confusions
Your question is too general. Can you ask some specific questions about your problem?
Re: beginner programmer - Abstract Concept Assignment - few confusions
"Add logic so that the total price method/function will give the total price of the meal including a 6% tax"
Did I do it correctly? Yes, no? If no, how can I correct it?
"Add a method that returns a Boolean named hasPlayPlace. Which returns true when this location has a playplace"
I did this differently vs the TacoBellSauce method. Don't know which one is more appropriate. Would like some enlightenment on that as well.
"Add a method/function that returns a String of what hot sauce you would like..ie hot, fire, mild"
I didn't get any errors with this one. But I don't think I did it right.
Last, What goes inside the location() method??
Re: beginner programmer - Abstract Concept Assignment - few confusions
Quote:
Did I do it correctly?
Test the program, look at the results. Are they correct?
Quote:
But I don't think I did it right.
Why?
Test it to see if it returns the correct result.
Quote:
What goes inside the location() method??
What is it defined to do? Does it do it?
Re: beginner programmer - Abstract Concept Assignment - few confusions
Quote:
Test the program, look at the results. Are they correct?
I guess I should make that test class and find out.
Quote:
Why?
Test it to see if it returns the correct result.
Quote:
What is it defined to do? Does it do it?
I have no idea what it's supposed to do. So idk what goes inside the method.
Re: beginner programmer - Abstract Concept Assignment - few confusions
Ask the instructor that assigned the problem. Re-read the assignment to see if you can understand it.