Wednesday, August 27, 2008

First minor assignment

Continuing the LunchCart class:

public class LunchCart
{
//properties of a LunchCart
private int num_Sandwiches;
private int num_Drinks;
private double price_of_sandwich;
private double price_of_Drinks;
private double total_value_of_sandwiches;
private double total_value_of_Drinks;

//setter methods for the LunchCart
public void setNumSandwiches(int x)
{
num_Sandwiches = x;
}

//getter methods for the LunchCart
public int getNumSandwiches()
{
return num_Sandwiches;
}

//setter method!
public void setNumDrinks(int y)
{
num_Drinks = y;
}


//getter method!
public int getNumDrinks()
{
return num_Drinks;
}

public static void main(String [] args)
{
LunchCart thisismylunchcart = new LunchCart();
thisismylunchcart.setNumSandwiches(55);
System.out.println(thisismylunchcart.getNumSandwiches());
thisismylunchcart.setNumDrinks(15);
System.out.println(thisismylunchcart.getNumDrinks());

}
}



Add the ability to set the other variables and calculate the value of the sandwiches and the value of the drinks.

Finish this assignment by next class. To do this, you'll most likely need to install Netbeans.

Here is how to install Java to use the command line.

Print out the code before next class. Even if you don't get all the getter and setter methods or calculations, print out what you have. This will be the last and only code that you have to print out. Usually you'll put it on an FTP server.