mojoopop
November 6th, 2009, 05:16 PM
so here is the big problem... the point of this assignment was to make a program that accepts 2 arguments of which only the first letter of each is read so i understand i would have to use the .charAt method to read Them
after it reads the strings and accepts the char values it is supposed to switch them out for strings after it has done that it must check the validity of the switch and output a message saying either ("your size is: +checksize") or ("invalid size") i understand that part
so here is the point of my problem i dont know how to get my argument that i inputed into my checkorder class from my orderform class? both the orderform and the check order use my pizza class.
here are my three classes so far...
p.s. i have also included the slides where i was given instructions on what to do in case you can not understand what i said...
/**
* Write a description of class Pizza here.
*
* @author Michael Wojtysiak
* @version 1.1
*/
public class Pizza
{
private String size;
private String toppings;
private static int PizzasSold;
public Pizza()
{
System.out.println("Pizza One - Default Constructor");
setSize("Small");
setToppings("Regular");
System.out.println("Size: " + size);
System.out.println("Toppings: " + toppings);
System.out.println("");
}
public Pizza(String setSize, String setToppings)
{
this.size = setSize;
this.toppings = setToppings;
System.out.println("Pizza Three - Two Parameter Constructor");
System.out.println("Size: " + size);
System.out.println("Toppings: " + toppings);
System.out.println("");
}
public Pizza(String setSize)
{
setSize("Medium");
setToppings("Regular");
System.out.println("Pizza Two - One Parameter Constructor");
System.out.println("Size: " + size);
System.out.println("Toppings: " + toppings);
System.out.println("");
}
public void setSize(String size)
{
this.size = size;
}
public void setToppings(String toppings)
{
this.toppings = toppings;
}
public String getSize()
{
return this.size;
}
public String getToppings()
{
return this.toppings;
}
public static int getPizzasSold()
{
return PizzasSold;
}
// public boolean equal(Pizza CompPizza)
// {
// if(this.getSize()==(CompPizza.getSize()))
// {
// if(this.getToppings()==(CompPizza.getToppings()))
// {
// return true;
//}
// else
// {
// return false;
// }
// }
// return false;
// }
public boolean equal(Pizza CompPizza)
{
if(this.getSize()==(CompPizza.getSize()))
{
if(this.getToppings()==(CompPizza.getToppings()))
{
return true;
}
else
{
return false;
}
}
return false;
}
private void calculatePrice()
{
}
public void display(String size, String toppings, double price)
{
System.out.println("Size: " + size);
System.out.println("Toppings: " + toppings);
System.out.println("Price: " + price);
}
}
import java.util.Scanner;
/**
*Has Pizzas
*
* @author Michael Wojtysiak
* @version 1.1
*/
public class OrderForm
{
public static void main(String args[])
{
String mySize = args[0];
String myToppings = args[1];
CheckOrder.checkSize(args[0]);
// CheckOrder.checkTopping(args[1]);
Pizza One = new Pizza();
Pizza Two = new Pizza(mySize);
Pizza Three = new Pizza(mySize,myToppings);
boolean Res = Three .equal(One);
if(Res == true)
{
System.out.println("They are the same!");
}
else
{
System.out.println("They are different!");
}
}
}
/**
* Write a description of class CheckOrder here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class CheckOrder
{
public static boolean checkSize(String size)
{
char num = size;
String checksize;
switch(num)
{
case 's' : checksize = "Small";
break;
case 'm' : checksize = "Medium";
break;
case 'l' : checksize = "Large";
break;
default : checksize = "Invalid";
}
if ((checksize == "Small")||(checksize == "Medium")||(checksize == "Large"))
{
System.out.println("Your Size is: " + checksize);
}
else
{
System.out.println("Invalid Size");
}
}
//if(boolean checkSize = true)
//{
// size = "Small";
// }
//else
//{
// System.out.println("Invalid");
// }
}
after it reads the strings and accepts the char values it is supposed to switch them out for strings after it has done that it must check the validity of the switch and output a message saying either ("your size is: +checksize") or ("invalid size") i understand that part
so here is the point of my problem i dont know how to get my argument that i inputed into my checkorder class from my orderform class? both the orderform and the check order use my pizza class.
here are my three classes so far...
p.s. i have also included the slides where i was given instructions on what to do in case you can not understand what i said...
/**
* Write a description of class Pizza here.
*
* @author Michael Wojtysiak
* @version 1.1
*/
public class Pizza
{
private String size;
private String toppings;
private static int PizzasSold;
public Pizza()
{
System.out.println("Pizza One - Default Constructor");
setSize("Small");
setToppings("Regular");
System.out.println("Size: " + size);
System.out.println("Toppings: " + toppings);
System.out.println("");
}
public Pizza(String setSize, String setToppings)
{
this.size = setSize;
this.toppings = setToppings;
System.out.println("Pizza Three - Two Parameter Constructor");
System.out.println("Size: " + size);
System.out.println("Toppings: " + toppings);
System.out.println("");
}
public Pizza(String setSize)
{
setSize("Medium");
setToppings("Regular");
System.out.println("Pizza Two - One Parameter Constructor");
System.out.println("Size: " + size);
System.out.println("Toppings: " + toppings);
System.out.println("");
}
public void setSize(String size)
{
this.size = size;
}
public void setToppings(String toppings)
{
this.toppings = toppings;
}
public String getSize()
{
return this.size;
}
public String getToppings()
{
return this.toppings;
}
public static int getPizzasSold()
{
return PizzasSold;
}
// public boolean equal(Pizza CompPizza)
// {
// if(this.getSize()==(CompPizza.getSize()))
// {
// if(this.getToppings()==(CompPizza.getToppings()))
// {
// return true;
//}
// else
// {
// return false;
// }
// }
// return false;
// }
public boolean equal(Pizza CompPizza)
{
if(this.getSize()==(CompPizza.getSize()))
{
if(this.getToppings()==(CompPizza.getToppings()))
{
return true;
}
else
{
return false;
}
}
return false;
}
private void calculatePrice()
{
}
public void display(String size, String toppings, double price)
{
System.out.println("Size: " + size);
System.out.println("Toppings: " + toppings);
System.out.println("Price: " + price);
}
}
import java.util.Scanner;
/**
*Has Pizzas
*
* @author Michael Wojtysiak
* @version 1.1
*/
public class OrderForm
{
public static void main(String args[])
{
String mySize = args[0];
String myToppings = args[1];
CheckOrder.checkSize(args[0]);
// CheckOrder.checkTopping(args[1]);
Pizza One = new Pizza();
Pizza Two = new Pizza(mySize);
Pizza Three = new Pizza(mySize,myToppings);
boolean Res = Three .equal(One);
if(Res == true)
{
System.out.println("They are the same!");
}
else
{
System.out.println("They are different!");
}
}
}
/**
* Write a description of class CheckOrder here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class CheckOrder
{
public static boolean checkSize(String size)
{
char num = size;
String checksize;
switch(num)
{
case 's' : checksize = "Small";
break;
case 'm' : checksize = "Medium";
break;
case 'l' : checksize = "Large";
break;
default : checksize = "Invalid";
}
if ((checksize == "Small")||(checksize == "Medium")||(checksize == "Large"))
{
System.out.println("Your Size is: " + checksize);
}
else
{
System.out.println("Invalid Size");
}
}
//if(boolean checkSize = true)
//{
// size = "Small";
// }
//else
//{
// System.out.println("Invalid");
// }
}