question archive Requirements of the JAVA program: Menu requirement: Your task is to start building a virtual car dealership

Requirements of the JAVA program: Menu requirement: Your task is to start building a virtual car dealership

Subject:Computer SciencePrice:3.86 Bought12

Requirements of the JAVA program:

Menu requirement: Your task is to start building a virtual car dealership. This will be a two-phased project. Second phase will be your last project of the semester.

1. Assume that you are only starting your dealership with 2 cars.

2. You need to build a menu that allows users to enter options. Possible options are 1 for "Add vehicles", 2 for "Display all vehicles" and 0 for "Quit. HINT: you can use switch statement to switch on int input

           a. Invalid input should throw a message for the user. Example: Invalid input, please try                         again

           b. Menu should be done on a while loop with 0 as the exit condition

3. Option 1(Add Vehicle) should ask 5 questions and capture 5 datapoints for each car. HINT: You will use scanner in a for loop to capture all inputs for vehicles. You will only have to loop twice since you only have 2 cars. Phase II will add more to your lot

4. Option 2(Display all vehicles) should call a display method from car class to display all cars

5. Option 0(Quit) should take you out of the loop and program should end

 

Class requirement:

VEHICLE CLASS

a. You will have to have a parent class called 'vehicle'. This class will have:

                       -3 private fields: Make(String), Model (String), Year(int)

                       -1 display method to display the 3 fields

                       -1 constructor to set values for the 3 fields based on user input. Hint: This method will have 3 parameters

CAR CLASS

You will have a child class called 'car'. HINT- extend it from vehicle

           -2 private fields: Doors(int), Price(int)

           -1 display method to display all 5 fields. HINT: call parent display method using super. first then print Doors and Price

           -1 constructor to set values for the 5 fields based on user input. HINT: This method will have 5 parameters and you'll have to call parent constructor first using super. By passing 5 parameters

DEALERSHIP CLASS

1. This class will have your main() method and call the car class by creating car object

2. Array: first thing you'll do in main is define an array of type car. You can user the number 2 within [] to make sure you can only hold 2 car info.

3. You will be printing the menu in the main method right after this

4. You will scan for input for the menu like you normally would

5. Once you have the input, you'll start your while loop. HINT- exit on 0

6. Within this while loop you'll have a switch case just like project 2

Case 1: a. You will need a for loop here with only 2 loops

           b. Will ask the users for 2 vehicle info: Make, Model, Year, Doors and Price. It will store after                     each ask and capture

           c. Once 5 values are captures for vehicle1, you'll store the info as Array elements. HINT:      myarray[i] = new car(make, model, year, doors, price). Here i will change to 0 and 1 due to the for loop

Case 2: a. You will need another for loop with only 2 loops

           b. You'll call the display method from car class. HINT myarray[i].displaycars. Here i will change to               0 and 1 due to the for loop

Case 0: You'll simply break like you did in project 2

HINT: Before exiting the while loop you'll have to print the menu again and do one more scan to capture the menu option

 

Error handling requirement: a. Please add try/catch blocks for all your user inputs

                                           b. If user inputs invalid data then catch block should display appropriate                                                         message to ask user for correct values

Expected output:

 

 

 

 

***Auto Dealership***

 

1 -- Add Vehicle

2 -- Display All Vehicles

0 -- Quit

1

please enter make:

ford

please enter model:

mustang

please enter year:

2010

please enter doors:

4

please enter price:

12000

please enter make:

toyota

please enter model:

supra

please enter year:

2015

please enter doors:

2

please enter price:

16000

***Auto Dealership***

 

1 -- Add Vehicle

2 -- Display All Vehicles

0 -- Quit

2

Make: ford

Model: mustang

Year: 2010

Doors: 4

Price: 12000

 

Make: toyota

Model: supra

Year: 2015

Doors: 2

Price: 16000

 

***Auto Dealership***

 

1 -- Add Vehicle

2 -- Display All Vehicles

0 -- Quit

 

PART 1 ==>> Class diagram for both vehicle and car classes

 https://app.lucidchart.com/users/register/personal?try=1

 

 

PART 2 ==>> The Java program itself

Rubrics:

  • Class diagrams: 25 points
  • All classes covered - 15 points
  • All components of the classes covered and parent child relationship shown - 10 points

Java program: 175 points

  • Program runs - 25 points
  • Program produces correct results -25 points
  • Menu is properly displayed(doesn't need to be exactly as the expected output above) - 10 points
  • All 3 class are defined - 25 points
  • Child class extends from parent - 10 points
  • Array of objects is created - 15 points
  • Error handling with try/catch blocks implemented for all user inputs - 50 points
  • Meaningful names used for all variables, package and class - 5
  • Proper indentation and neatness of the program - 5
  • Appropriate comments - 5

 

Option 1

Low Cost Option
Download this past answer in few clicks

3.86 USD

PURCHASE SOLUTION

Option 2

Custom new solution created by our subject matter experts

GET A QUOTE

rated 5 stars

Purchased 12 times

Completion Status 100%

Related Questions