I have written a basic program with 2 source code files demonstrating the
new operator and basic method calls. On my computer at school, I receive an
error on line 7 of the TestPizza.java file regarding the new operator. When
I move the code to another computer, I do not receive the error and the
program operates just fine. I am using Java2 1.4.2. I have checked the
path in the System Variables and it is set up correctly. Other programs
work just fine except for this particular program. Other people in my class
were having the same problem and still others were not. All of us are using
EDIT to write the programs, and compile via the command line "javac
TestPizza.java" command.
Any ideas why the PC is having a problem with the "new" operator?
Thanks in advance for any responses.
Tony
****************** First Source Code File Pizza.java
*******************
//create a class to store info abouty a pizza
class Pizza
{
// the private data members
private int diameter;
private double price;
private String toppings;
// the public get and set methods
public void setDiameter(int amt)
{
diameter = amt;
}
public int getDiameter()
{
return diameter;
}
public void setPrice(double amt)
{
price = amt;
}
public double getPrice()
{
return price;
}
public void setToppings(String str)
{
toppings = str;
}
public String getToppings()
{
return toppings;
}
}// end class Pizza
************** second source code file TestPizza.java
*******************
// client to test the Pizza class
class TestPizza
{
public static void main(String args[])
{
Pizza pie = new Pizza();
pie.setDiameter(15);
pie.setPrice(8.95);
pie.setToppings("Mushroom, Pepperoni");
System.out.println("You have ordered a pizza with "
+ pie.getToppings()
+ " toppings,\nwith a diameter of "
+ pie.getDiameter()
+ " and a price of "
+ pie.getPrice());
}
}