Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 8th, 2008, 07:59 AM
c++geek c++geek is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Posts: 2 c++geek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 10 sec
Reputation Power: 0
Help with restaurant program (Inheritance related)

I am trying to make a program which is a restaurant ordering system. But cannot get it to compile.

here are the java files I am using.

drink.java
Quote:
import java.util.*;

public class Drink extends Order
{
private int ID;
private int name;

public Drink(int ID , String Name)
{
this.ID = ID;
this.name = name;
Drink one = new Drink();
Drink two = new Drink();
one.name = "Red Wine 750ml";
two.name = "Mineral Water 1.5l";
}


public int getID ()
{
return ID;
}
public String getName()
{
return name;
}
}


food.java
Quote:
import java.util.*;

public class Food extends Order
{
private int id;
private int name;

public Food(int id, String name)
{
this.id = id;
this.name = name;
Food one = new Food();
Food two = new Food();
one.name = "Steak with Potatoes";
two.name = "Pasta Salad";
}
public int getID()
{
return id;
}
public String getName()
{
return name;
}
}


Orders.java
Quote:
public class Orders
{
private String command;

public Orders(String command)
{
this.Orders = newOrder();
}
}


restaurant.java
Quote:
import java.util.*;
import cs1.*;

public class Restaurant {
public static void main(String[] args) {

Locale.setDefault(Locale.UK); // So monetary output uses £

Orders orders = new Orders();

Menu m1 = new Menu();
boolean nextCustomer = false;
String response;

m1.addItem("Red Wine 750ml", 11.50);
m1.addItem("Mineral Water 1.5l", 1.50);
m1.addItem("Steak and Potatoes", 9.00);
m1.addItem("Pasta Salad", 7.80);

Waiter w1 = new Waiter("Kevin");

do{
Customer c = new Customer(m1);
orders.addCustomer(c);
s1.greet();
s1.serve(c, m1);
System.out.print("Next customer? (y/n): ");
response = Keyboard.readString();
nextCustomer = response.equals("y");
} while (nextCustomer);

orders.displayOrders();
orders.displayTotal();
}
}

Reply With Quote
  #2  
Old May 22nd, 2008, 06:08 PM
faceninja faceninja is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 faceninja User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 46 m 20 sec
Reputation Power: 0
It would help if you said what the compiler errors were, as "import cs1.*;" means we can't test compile it ourselves.

Reply With Quote
  #3  
Old June 4th, 2008, 02:21 AM
tictactactics tictactactics is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 tictactactics User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 6 m 17 sec
Reputation Power: 0
Code:
public class Drink extends Order
{
private int ID;
private int name;

public Drink(int ID , String Name)
{


I don't know if this would be a problem, but after looking at this quickly.... since Java is case-sensitive, it might be a problem that "Name" is capitalized in the "public Drink" line but it's just "name" when you initialize it at first....

so maybe...
Code:
public class Drink extends Order
{
private int ID;
private String name;

public Drink(int ID , String name)

would work....

Note that I also made "name" a string when it's initialized, instead of an int.

But hey, I'm a tooootal noooob. I hope this helps though ^_^

Reply With Quote
  #4  
Old June 5th, 2008, 11:20 AM
TopSecret TopSecret is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 TopSecret User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 11 sec
Reputation Power: 0
tictactactics ir right. Also:
public class Orders
{
private String command;

public Orders(String command)
{
this.Orders = newOrder();
}
}

Also there is no member (attribute) on the Orders class named Orders to assign the newOrder() result to. These errors were certainly caught by the compiler and the reasons for compilation failure given.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Help with restaurant program (Inheritance related)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT