Question
I need help with this assignment i created a menu for a car dealership basically and Below i will post my Menu/Tester i have so
I need help with this assignment i created a menu for a car dealership basically and Below i will post my Menu/Tester i have so far named VehicleDetails.java I need help editing my code and making it right like the direction below says dont pay to much attention to my comments i have to add new ones to the program also.
Assignment
It says that now you will need to convert the use of Array Lists to Linked Lists.I need help changing this part im no sure what to do exactly/ You will also need to maintain order in your systemwhether alphabetical or numerical. Note: take great care when implementing these types of lists, it is very easy to lose track of your various nodes. As for storage, you will need to implement one form of storage (at a minimum) for your data. You will use files to do this. The difference between the files used in CSCI 140 and this course, is the use of objects. You will store and read objects. You do not have to store every piece of data (although this will be a true test of what you know), you may choose one type of data OR if you have one large object, you are storing all of your data.
VehicleDetails.java
import java.util.ArrayList;
import java.util.Scanner;
public class VehicleDetails {
public static void main(String[] args) {
int playAgain = 1; {// 1 is yes,
while (playAgain == 1) {
// admin or regular
System.out.println("Choose between the following options?");
System.out.println("1 Administrator Or 2 Regular Customer");
Scanner input = new Scanner(System.in);
int op = input.nextInt();
if (op == 1) {
// Admin
System.out.println("Which option would you like to do?");
System.out.println("Can only view vehicle details from name choosen in add vehicle");// can only view if you add a vehicle
System.out.println("1 Add A Vehicle, 2 Remove A Vehicle, 3 View Car Detail, 4 Switch Users");
op = input.nextInt();
while(op != 4) {
if (op == 1) {
int addVehicle = 1;//1 is Add Vehicle
System.out.println("Choose one of the following numbers");
System.out.println("1 Add Truck");
System.out.println("2 Add Car");
System.out.println("3 Add Boat");
System.out.println("4 Add Plane");
int type = input.nextInt();
System.out.println("What is the name?");
String name = input.next();
System.out.println("How many wheels?");
int numwheels = input.nextInt();
System.out.println("What is the make?");
String make = input.next();
System.out.println("What is the mpg?");
int mpg = input.nextInt();
if (type == 1) {
System.out.println("What is the bedsize?");
int bedsize = input.nextInt();
list.add(new Truck(name, numwheels, make, mpg, bedsize));
}
else if (type == 2) {
System.out.println("How many doors does it have?");
int numDoors = input.nextInt();
list.add(new Car(name, numwheels, make, mpg, numDoors));
}
else if (type == 3) {
System.out.println("What is the motortype?");
String motortype = input.next();
list.add(new Boat(name, numwheels, make, mpg, motortype));
}
else if (type == 4) {
System.out.println("How many wings does it have?");
int numWings = input.nextInt();
list.add(new Plane(name, numwheels, make, mpg, numWings));
}
}
else if (op == 2) {
int removeCar = 2;//2 is Remove Vehicle
// Remove Car
System.out.println("Please enter vehicle you want to remove?");// Remove Vehicle
System.out.println("Type in vehicle you want to remove Truck, Car, Boat, or Plane");
String select = input.next();
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getName() == select ) {
list.remove(i);
}
}
}
else if (op == 3) {
int viewDetail = 3;//3 View Car Details
System.out.println("Please enter which vehicle name details you want to view?");
System.out.println("Type in name of vehicle you chose in add vehicle");
String select = input.next();
for (int i = 0; i < list.size();i++) {
String getN = list.get(i).getName();
if (getN.equalsIgnoreCase(select)) {
System.out.println(list.get(i));
}
}
}
System.out.println("Which option would you like to do?");
System.out.println("Can only view vehicle details from name choosen in add vehicle");
System.out.println("1 Add A Vehicle, 2 Remove A Vehicle, 3 View Car Detail, 4 Switch User");
op = input.nextInt();
}
}
// regular
else if (op == 2) {
if(list.isEmpty()==true){
System.out.println("There are no cars added to view administrator must add cars first");
}
else {
int viewDetail = 3;//3 View Car Details
System.out.println("Please enter which vehicle details you want to view?");
System.out.println("Type in name of vehicle the administrator added");
String select = input.next();
for (int i = 0; i < list.size();i++) {
if (list.get(i).getName().equalsIgnoreCase(select)) {
System.out.println(list.get(i));
}
}
System.out.println("Do you want to run the program again?");
System.out.println("1 for yes or 2 for no");
playAgain = input.nextInt(); //
{
{
}
}
}
}
}
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started