Outlab 2
Due: February 19th (Monday sections)/20th(Tuesday section)
You have a car dealership. You need to keep track of inventory and customers.
- You need a Driver class.
- You need a Car class.
- You need a customer class.
You are a small auto dealership, you only have five cars at the start of the day. You need to keep track of what type of car you have in inventory, the price of the car and year of the car. Five instances of the Car class.
This program will keep track of one day's work. In this one day you will serve three customers.
Each customer will be logged after they leave. You will need to keep track of the customers name, phone number and what type of car they bought, if the bought one. 2 of 3 customers will buy a car.
Hint: Your Customer class constructor will be passed the instance of the
car that they bought, or null if none. You will also need a flag in the
Car class saying whether it's been sold or not, use a boolean.
At the end of the day you will be able to print the 3 cars left in your inventory.
And you will print the results of your 3 customers: name, phone and which car they bought.
Example of my main program:
public static void main(String [] args)
{
Car c1 = new Car("Tundra", "2005");
Car c2 = new Car("Caravan", "2003");
Car c3 = new Car("ForeRunner", "1998");
Car c4 = new Car("Camry", "2002");
Car c5 = new Car("Sierra", "2005");
Customer p1 = new Customer("Sally", "555-6789", c1);
Customer p2 = new Customer("Harry", "555-5959", c3);
Customer p3 = new Customer("Jake", "555-0303", null);
System.out.println("Current inventory levels: ");
if(c1.ifNotSold())
System.out.println(c1.getYear() + " " + c1.getType());
if(c2.ifNotSold())
System.out.println(c2.getYear() + " " + c2.getType());
if(c3.ifNotSold())
System.out.println(c3.getYear() + " " + c3.getType());
if(c4.ifNotSold())
System.out.println(c4.getYear() + " " + c4.getType());
if(c5.ifNotSold())
System.out.println(c5.getYear() + " " + c5.getType());
System.out.println("\nCustomers data: ");
System.out.println(p1.getName() + ", " + p1.getPhone() + ", " + p1.getCar());
System.out.println(p2.getName() + ", " + p2.getPhone() + ", " + p2.getCar());
System.out.println(p3.getName() + ", " + p3.getPhone() + ", " + p3.getCar());
}
|
Output of Driver above:
Current inventory levels:
2003 Caravan
2002 Camry
2005 Sierra
Customers data:
Sally, 555-6789, 2005 Tundra
Harry, 555-5959, 1998 ForeRunner
Jake, 555-0303, No Car bought
|
Due and Grading:
You will turn in your three .java files to your lab TA before the beginning of the next lab class. February 19th/20th.
The grading will be based on:
- The program performs accurately.
- The output format matches the format described in the problem.
- The program is well commented.
- The program variables, methods and classes use meaningful names.
- The program uses indentation and white space appropriately.
- The program uses classes and methods appropriately
|