Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 10 of 10

Thread: beginner programmer - Abstract Concept Assignment - few confusions

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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:
    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?
    Last edited by Norm; December 1st, 2012 at 04:59 PM. Reason: changed \ to / in code tag


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: beginner programmer - Abstract Concept Assignment - few confusions

    Here's what I thought worked?
    If you are getting errors, please copy the full text and paste it here.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: beginner programmer - Abstract Concept Assignment - few confusions

    Quote Originally Posted by Norm View Post
    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.

  4. #4
    Junior Member
    Join Date
    Dec 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: beginner programmer - Abstract Concept Assignment - few confusions

    Bump to anyone who can answer?

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: beginner programmer - Abstract Concept Assignment - few confusions

    willing to make a paypal donation to anyone who can help me out...

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: beginner programmer - Abstract Concept Assignment - few confusions

    Your question is too general. Can you ask some specific questions about your problem?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Dec 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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??

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: beginner programmer - Abstract Concept Assignment - few confusions

    Did I do it correctly?
    Test the program, look at the results. Are they correct?

    But I don't think I did it right.
    Why?
    Test it to see if it returns the correct result.

    What goes inside the location() method??
    What is it defined to do? Does it do it?
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Dec 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: beginner programmer - Abstract Concept Assignment - few confusions

    Test the program, look at the results. Are they correct?
    I guess I should make that test class and find out.

    Why?
    Test it to see if it returns the correct result.

    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.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. JADE---Sending an Concept including an concept
    By HansDampf in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 25th, 2014, 12:22 AM
  2. tips for beginner programmer
    By Syahdeini in forum The Cafe
    Replies: 1
    Last Post: July 11th, 2012, 09:31 PM
  3. beginner programmer trouble
    By scottey313 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 30th, 2011, 01:41 PM
  4. another assignment from beginner programmer trouble
    By scottey313 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 30th, 2011, 01:13 PM
  5. Beginner java programmer!
    By chrisivey1980 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: April 23rd, 2011, 03:06 AM

Tags for this Thread