Background Information:

A local auto sales company, AutoMore, has asked you to develop and application for them. This application will allow the manager to keep track of their inventory with a simple, textbased user interface. A sample output file is provided on Moodle to give you an idea of what this application can do.

Part 1

Be sure to read through all items before you begin. The following descriptions are not written in any particular order. You should apply the iterative development techniques we've stressed this semester to develop your code in an appropriate fashion.

Organization

All classes in your Eclipse project will be stored in one of the following packages only:

edu.westga.cs6311.carlot.controller
edu.westga.cs6311.carlot.model
edu.westga.cs6311.carlot.tests
edu.westga.cs6311.carlot.view

You are encouraged to develop a set of informal tests for your model classes and place that code into the tests package, however no points will be awarded for testing (we'll focus much more on formal testing in the Spring semester)

Package Model

Develop a class named Car such that it defines:

Instance Variables:

  • The make (String)
  • The model (String)
  • The price as a whole number of dollars (int)

Methods:

  • A 3parameter constructor that accepts the values to be stored in the instance variables. Be sure to error check each parameter so that if invalid values are passed, the default value for that data type is stored (the Empty String for String variables and zero for numeric variables). Use these values to initialize the instance variables.
  • Accessors ('getters') for all instance variables
  • A mutator ('setter') for the price only. This method will accept the new price and not return anything. If the new value passed is less than or equal to 0, simply return without changing anything.
  • A toString method used to return a String representation of the object. This String must list each of the data members with the number of characters specified and exactly one (1) blank space between each value. Note that there is a dollar sign character before the price and the price should be listed with the decimal place in the same column for each item as follows: see image.
  • For example: see image.

** It is OK to assume that the Make and Model together will be no more than 15 characters (so that the Make, Model, and the blank space between them will always fit) and the price won't be more than $999,999.

HINT: There is a method in the String class named format, which will work similar to printf (format returns a String, whereas printf prints the formatted data on the console). Please see the textbook and/or Java API for more details on how this can help you here.

Develop a class named CarLot such that it defines:

Instance Variables:

  • An ArrayList of Car objects

Methods:

  • A 0parameter constructor that instantiates the instance variable
  • createLot - This method is going to be used to start the standard inventory of a car lot. This will include the following cars:
Chevy Camaro $25,000
Ford Mustang $26,120
Dodge Charger $27,595
  • findCar - This method will accept two Strings holding a car's make and model. It will then search the inventory and return the first Car that matches these values. Note that this search will not be case sensitive (so "Chevy" is treated the same as "chevy" or "chEvy"). If no such car is present, this method will return null.
  • addCar - This method will accept 3 parameters needed to create a Car. It will then create the object and add it to the inventory.
  • getLeastExpensive - This method will search the inventory and return the least expensive car. If there are no cars in stock, this will return null. To keep things simple, we will assume that no two cars will have the same price.
  • getMostExpensive - This method will search the inventory and return the most expensive car. If there are no cars in stock, this will return null.
  • getTotalValue - This method will calculate and return the total value of all cars on the lot.
  • getAveragePrice - This method will calculate and return the average car cost. Be sure not to round this value. If there are no cars on the lot, then this will return 0.
  • toString - This method will return a String containing a complete description of the car lot. If the lot is empty, this String should say so; otherwise it will include a listing of each Car on its own line (hint: use the Car's toString method), followed by a line telling the number of cars and three lines listing the most and least expensive cars and the average price (be sure to format this average to exactly 2 decimal places). For example:
CHEVY CAMARO $ 25000
DODGE CHARGER $ 27595
FORD MUSTANG $ 26120
Number of cars: 3
Most expensive car: DODGE CHARGER $ 27595
Least expensive car: CHEVY CAMARO $ 25000
Average cost: $26238.33

Package View

Develop a class named AutoMoreTUI such that it defines:

Instance Variables (these are the only acceptable instance variables):

  • An CarLot object
  • A Scanner object

Methods:

  • A 1parameter constructor that accepts a CarLot object and initializes the instance variables.
  • runManager - This method serves as the 'director' of the user interface by calling on private helper methods to do their work, as appropriate.
  • A variety of other private helper methods that will provide the functionality for allowing the user to interact with the program and display the necessary output. Every method should perform exactly one cohesive task and should have an appropriate name to describe this task. As a general rule, each menu option will have at least one method associated with it.

Application Functionality

  • The user will interact with the application using a consolebased, textual user interface (TUI). This interface should be menu driven. To keep things simple, menu options will be numbered so that the user can type a single integer value as a menu choice (instead of typing in a character or word). See the sample output for an example on how this might be done.
  • There are a number of methods defined to return null. Be aware that null is a programmer's term and should never be displayed to a user. Instead, be sure your application presents appropriate words and feedback for 'regular people' (nonprogrammers)
  • Menu options include:

1. Create a new car lot

This should call the createLot method to add the standard cars.

2. Add a new car to the inventory

The application will allow the user to enter the car's information and have the appropriate object added to the car lot. Once this action is complete, a confirmation message should be printed on the screen describing the car that was just added.

You can assume that the user will enter the appropriate data type (integer, floating point number, etc) but you aren't guaranteed what value will be entered. If the user enters a price less than or equal to 0, the application should force the user to try again until they enter a positive value.

3. View the current inventory

This should display a listing of each car on its own line and include the total number of cars, the most and least expensive, and the average price.

4. Quit the application

The application will display an appropriate message to thanking the user for using the application before closing appropriately.

Again, you can assume that the user will enter an integer value as a menu choice, but you don't know what integer they will enter. Be sure that if they choose a menu option that's not available that you display an appropriate message and show the menu again.

Package Controller

Develop a class named AutoMoreDriver such that it defines a main method as the entry point into the application. It will create an instance of the CarLot class. It will then pass this object to the AutoMoreTUI constructor and use that object to call runManager.

Part 2

Be sure to read through all items before you begin. The following descriptions are not written in any particular order. You should apply the iterative development techniques we've stressed this semester to develop your code in an appropriate fashion.

Model

Develop a class named Shopper such that it defines:

Instance Variables (only):

  • Name (String)
  • Amount to spend (double)
  • The car they will purchase (Car)

Methods:

  • A 2parameter constructor that accepts the Shopper's name and amount they have available to spend. Be sure the values passed are valid, otherwise store the default value for that type.
  • Getter methods
  • enoughToPurchase - This method accepts a Car object and return a boolean value.
  • purchaseCar - This method accepts a Car object and not return any value. If this Shopper has enough money, then this method will add it to the instance variable. It will also calculate and set the amount of money the person has left after purchasing the car. Note: we will not allow the person to purchase more than one car at a time.

Package View

Develop a class named ApplicationTUI such that it defines:

Instance Variables (only):

  • An CarLot object
  • A Scanner object

Methods:

  • A 1parameter constructor that accepts a CarLot object and initializes the instance variables.
  • runApplication - This method serves as the 'director' of the main application. Basically this method is just going to give the user the ability to choose to enter the manager's application (where new items can be added, etc) or the shopper's application (where shoppers can add items to a cart and purchase them).
  • A variety of other private helper methods that will provide the functionality for allowing the user to interact with the program and display the necessary output. Every method should perform exactly one cohesive task and should have an appropriate name to describe this task. As a general rule, each menu option will have at least one method associated with it.

Modify the existing AutoMoreDriver class such that it makes an ApplicationTUI object, and then uses this object to call runApplication method instead of calling runManager.

Develop a class named ShopperTUI such that it defines:

Instance Variables (only):

  • A CarLot object
  • A Shopper object
  • A Scanner object

Methods:

  • A 1parameter constructor that accepts a CarLot object and initializes the instance variables
  • getShopperInformation - This private helper method will accept no parameters and not return any value. Code inside this method will prompt the user for a name and an amount to spend. With that information, it will then initialize the instance variable.
  • runShopper - This method will serve as the 'director' of the user interface by calling on private helper methods to do their work, as appropriate.
  • A variety of other private helper methods that will provide the functionality for allowing the user to interact with the program and display the necessary output. Every method should perform exactly one cohesive task and should have an appropriate name to describe this task. As a general rule, each menu option will have at least one method associated with it.

Shopper Functionality

The user will interact with the application using a consolebased, textual user interface (TUI). This interface should be menu driven. To keep things simple, menu options will be numbered so that the user can type a single integer value as a menu choice (instead of typing in a character or word). See the sample output for an example on how this might be done.

Menu options include:

1. View all cars on lot
This option will display a listing of all cars on the car lot

2. View cars by make
This will display a listing of only the cars on the lot made by the manufacturer provided

3. View money remaining
This option will display the amount of money the shopper has left to spend

4. Purchase car
This option will allow the user to select a car and purchase it.

5. Quit shopper application
This option will end the shopper's menu and return to the application's main menu

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.