How to make a receipt with three classes

I'm having trouble printing the receipt in the console

Page 1 of 1

3 Replies - 8487 Views - Last Post: 27 October 2008 - 04:38 PM Rate Topic: -----

#1 fbhernandez  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-October 08

How to make a receipt with three classes

Posted 27 October 2008 - 11:55 AM

Hi, I'm supposed to create a customer order for a pizza company and have three classes. one is the Pizzaapp.java, Pizzaorder.java and Pizzareceipt.java. So far i've written the pizzaapp, pizzaorder and some part of the pizzareceipt. I am supposed to use the JOptionPane method to dispaly a dialog box and to input the data there. I am having trouble with showing the information i've inputed on the Pizzaorder and showing it on the Pizzareceipt console. Can some one please help me. I've included an attachment of the Description on how the problem is supposed to look and the format. Thanks

Pizza Order CODE::

import javax.swing.JOptionPane;

public class PizzaOrder
{
public void Takecustomerorder()
{
String Pizzatype = JOptionPane.showInputDialog ("What kind of pizza");
String Pizzanumstr = JOptionPane.showInputDialog("How many Pizza");
String toppings = JOptionPane.showInputDialog ("How many toppings");
String price = JOptionPane.showInputDialog ("How much");

PizzaReceipt AR = new PizzaReceipt();
AR.writeHeader();
AR.writeDetailLine();
AR.writeTotalLine();


Pizza Receipt CODE:

public class PizzaReceipt
{

public void writeHeader()
{
System.out.println ("Bambino's Pizza - Branch Manager Farid Hernandez");
}

public void writeDetailLine (String Pizzatype; Double price; String toppings; int Pizzanumstr);
{
System.out.println ("pizza" + Pizzatype + "number" + numOfPizza + "@" + price + "="
+ price * numOfPizza);

System.out.println ( "Extratopping" + toppings.length( )+ "@ .50 =" + toppings.length);
}

public void writeTotalLine() {
// TODO Auto-generated method stub
{
System.out.println ("Subtotalamount" + "tax" + "@" + "8%" + "Finalcost");

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: How to make a receipt with three classes

#2 Gloin  Icon User is offline

  • Expert Schmexpert...
  • member icon

Reputation: 235
  • View blog
  • Posts: 4,489
  • Joined: 04-August 08

Re: How to make a receipt with three classes

Posted 27 October 2008 - 01:01 PM

Well.. Start with the pizza-class..

Try to think of what is important about a pizza in this context (ingredients, price) and think how you can represent these 'attributes' using variables.
Make methods to get the price of each ingredient on the pizza and to add ingredients to the pizza.

There won't be very many things to consider here (it's not a very big program).

Next take the receipt-class..

On the reciept you put pizza-objects so you need a method to add pizzas to the receipt. Use the pizza-methods to calculate the total price of the entire pizza. Have a method that can sum up the price of all pizzas + tax & tips.

Last the order-class..

Should just contain methods to read input from the user/customer. This class could create the pizza objects and use the pizza-class methods to add ingredients to the pizza.

Something like that..

This post has been edited by Gloin: 27 October 2008 - 01:16 PM

Was This Post Helpful? 0
  • +
  • -

#3 fbhernandez  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 27-October 08

Re: How to make a receipt with three classes

Posted 27 October 2008 - 04:29 PM

I've tried that but the professor does not want the variables defined on the orderapp. Thats why I have to use the JOptionPane.showinputdialog. Therefore my problem is that the pizza type, how many pizzas, etc, are not printing on the receip. Can you please give me an example of a code that would do that? thanks


View PostGloin, on 27 Oct, 2008 - 01:01 PM, said:

Well.. Start with the pizza-class..

Try to think of what is important about a pizza in this context (ingredients, price) and think how you can represent these 'attributes' using variables.
Make methods to get the price of each ingredient on the pizza and to add ingredients to the pizza.

There won't be very many things to consider here (it's not a very big program).

Next take the receipt-class..

On the reciept you put pizza-objects so you need a method to add pizzas to the receipt. Use the pizza-methods to calculate the total price of the entire pizza. Have a method that can sum up the price of all pizzas + tax & tips.

Last the order-class..

Should just contain methods to read input from the user/customer. This class could create the pizza objects and use the pizza-class methods to add ingredients to the pizza.

Something like that..

Was This Post Helpful? 0
  • +
  • -

#4 Gloin  Icon User is offline

  • Expert Schmexpert...
  • member icon

Reputation: 235
  • View blog
  • Posts: 4,489
  • Joined: 04-August 08

Re: How to make a receipt with three classes

Posted 27 October 2008 - 04:38 PM

Sorry, I don't quite understand what you meant by that?!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1