Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

any help would be great Add a driver class name sp2017LAB3 vehicleDealershop you

ID: 3791129 • Letter: A

Question



any help would be great

Add a driver class name sp2017LAB3 vehicleDealershop yourtastname that do the requirement asking for OBJECTIVES: Practice using Java ArrayList dass REQUIREMENT and How TO DOITHE LAB PART2 Add the following part to the previous project with the folowing step by strep (pseudo-code) Declare a data structure of ArrayList with the aize 25 -insert 3 cars/motocycles with information that are entered fram the keyboard Show all 3 nodes that have inserted to the Arraylist data structure -use a for loop to insert number 1 to 100 to the above data structure of ArrayList Display the size of the above ArrayList -Remove the one above ca motocycle from the ArrayList data structure with one of the VIN displyed at above showAl Then display the size of the ArrayList structure -Get and display the information of nodes at the location 45 Change the value a location 45 to 2016 Display the information at location again. -Use JoptionPane to display the message 'Congratulationl You are successful on ArrayList with four operations add, get remove and set

Explanation / Answer

public class SP2017Lab3_Vehicle_Smith {
   protected int vinNumber;
   protected String color;
   protected String make;
   protected String model;
   protected int year;
   protected String manufacturer;

   public SP2017Lab3_Vehicle_Smith(int vinNumber, String color, String make,
           String model, int year, String manufacturer) {
       this.vinNumber = vinNumber;
       this.color = color;
       this.make = make;
       this.model = model;
       this.year = year;
       this.manufacturer = manufacturer;
   }

   public void forward(int miles) {
       System.out.println("move forward " + miles + " miles ");
   }

   public void backward(int miles) {
       System.out.println("move backword " + miles + " miles ");
   }

   public void turnleft() {
       System.out.println("turn left");
   }

   public void turnright() {
       System.out.println("turn right");
   }

   public int hashCode() {
       final int prime = 31;
       int result = 1;
       result = prime * result + ((color == null) ? 0 : color.hashCode());
       result = prime * result + ((make == null) ? 0 : make.hashCode());
       result = prime * result
               + ((manufacturer == null) ? 0 : manufacturer.hashCode());
       result = prime * result + ((model == null) ? 0 : model.hashCode());
       result = prime * result + vinNumber;
       result = prime * result + year;
       return result;
   }

   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (obj == null)
           return false;
       if (getClass() != obj.getClass())
           return false;
       SP2017Lab3_Vehicle_Smith other = (SP2017Lab3_Vehicle_Smith) obj;
       if (color == null) {
           if (other.color != null)
               return false;
       } else if (!color.equals(other.color))
           return false;
       if (make == null) {
           if (other.make != null)
               return false;
       } else if (!make.equals(other.make))
           return false;
       if (manufacturer == null) {
           if (other.manufacturer != null)
               return false;
       } else if (!manufacturer.equals(other.manufacturer))
           return false;
       if (model == null) {
           if (other.model != null)
               return false;
       } else if (!model.equals(other.model))
           return false;
       if (vinNumber != other.vinNumber)
           return false;
       if (year != other.year)
           return false;
       return true;
   }

   public int getVinNumber() {
       return vinNumber;
   }

   public void setVinNumber(int vinNumber) {
       this.vinNumber = vinNumber;
   }

   public String getColor() {
       return color;
   }

   public void setColor(String color) {
       this.color = color;
   }

   public String getMake() {
       return make;
   }

   public void setMake(String make) {
       this.make = make;
   }

   public String getModel() {
       return model;
   }

   public void setModel(String model) {
       this.model = model;
   }

   public int getYear() {
       return year;
   }

   public void setYear(int year) {
       this.year = year;
   }

   public String getManufacturer() {
       return manufacturer;
   }

   public void setManufacturer(String manufacturer) {
       this.manufacturer = manufacturer;
   }

   public String toString() {
       return "SP2017_Lab3_Smith [vinNumber=" + vinNumber + ", color=" + color
               + ", make=" + make + ", model=" + model + ", year=" + year
               + ", manufacturer=" + manufacturer + "]";
   }

}

public class SP2017Lab3_Car_murali extends SP2017Lab3_Vehicle_Smith {

   private int noofPassengers;
   private int noofDoors;

   public SP2017Lab3_Car_murali(int vinNumber, String color, String make,
           String model, int year, String manufacturer) {
       super(vinNumber, color, make, model, year, manufacturer);
       // TODO Auto-generated constructor stub
   }

   public int getNoofPassengers() {
       return noofPassengers;
   }

   public void setNoofPassengers(int noofPassengers) {
       this.noofPassengers = noofPassengers;
   }

   public int getNoofDoors() {
       return noofDoors;
   }

   public void setNoofDoors(int noofDoors) {
       this.noofDoors = noofDoors;
   }

   public int hashCode() {
       final int prime = 31;
       int result = super.hashCode();
       result = prime * result + noofDoors;
       result = prime * result + noofPassengers;
       return result;
   }

   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (!super.equals(obj))
           return false;
       if (getClass() != obj.getClass())
           return false;
       SP2017Lab3_Car_murali other = (SP2017Lab3_Car_murali) obj;
       if (noofDoors != other.noofDoors)
           return false;
       if (noofPassengers != other.noofPassengers)
           return false;
       return true;
   }

   public String toString() {
       return "SP2017Lab3_Car_murali [noofPassengers=" + noofPassengers
               + ", noofDoors=" + noofDoors + ", vinNumber=" + vinNumber
               + ", color=" + color + ", make=" + make + ", model=" + model
               + ", year=" + year + ", manufacturer=" + manufacturer + "]";
   }

}

public class SP2017LAB3_MotorCycle_Murali extends SP2017Lab3_Vehicle_Smith {

   private boolean hasSideCar;

   public SP2017LAB3_MotorCycle_Murali(int vinNumber, String color,
           String make, String model, int year, String manufacturer,
           boolean hasSideCar) {
       super(vinNumber, color, make, model, year, manufacturer);
       this.hasSideCar = hasSideCar;
   }

   public boolean isHasSideCar() {
       return hasSideCar;
   }

   public void setHasSideCar(boolean hasSideCar) {
       this.hasSideCar = hasSideCar;
   }

   public int hashCode() {
       final int prime = 31;
       int result = super.hashCode();
       result = prime * result + (hasSideCar ? 1231 : 1237);
       return result;
   }

   public boolean equals(Object obj) {
       if (this == obj)
           return true;
       if (!super.equals(obj))
           return false;
       if (getClass() != obj.getClass())
           return false;
       SP2017LAB3_MotorCycle_Murali other = (SP2017LAB3_MotorCycle_Murali) obj;
       if (hasSideCar != other.hasSideCar)
           return false;
       return true;
   }

   public String toString() {
       return "SP2017LAB3_MotorCycle_Murali [hasSideCar=" + hasSideCar
               + ", vinNumber=" + vinNumber + ", color=" + color + ", make="
               + make + ", model=" + model + ", year=" + year
               + ", manufacturer=" + manufacturer + "]";
   }

}

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class VehicleUnsortedOptimisedArray {
private List<SP2017Lab3_Vehicle_Smith> list=new ArrayList<SP2017Lab3_Vehicle_Smith>();
   private int size;
   private int vehicleArraySize;
   public VehicleUnsortedOptimisedArray(int size, int vehicleArraySize) {
       this.size = size;
       this.vehicleArraySize = vehicleArraySize;
   }
   public void insert(SP2017Lab3_Vehicle_Smith vehicle){
      
       list.add(vehicle);
      
   }
  
   public void fetch(SP2017Lab3_Vehicle_Smith vehicle)
   {
       int count=0;
       for(SP2017Lab3_Vehicle_Smith vehi:list)
       {
           if(vehi.equals(vehicle))
           {
               count++;
               System.out.println(vehi);
               break;
           }
          
       }
       if(count==0)
       {
           System.out.println("vehicle not found to fetch");
       }
      
   }
  
   public void delete(SP2017Lab3_Vehicle_Smith vehicle)
   {
       int count=0;
       for(SP2017Lab3_Vehicle_Smith veh:list)
       {
           if(veh.equals(vehicle))
           {
               list.remove(vehicle);
               count++;
               System.out.println("vehicle is deleted");
           }
       }
       if(count==0)
       {
           System.out.println("the vehicle not found to remove in the vehicles");
       }
      
   }
   public void update(SP2017Lab3_Vehicle_Smith vehicle)
  
   {
       int count=0;
       for(SP2017Lab3_Vehicle_Smith veh:list)
       {
           if(veh.vinNumber==vehicle.vinNumber)
           {
           Scanner scanner=new Scanner(System.in);
           System.out.println("enter the color name for changing");
           //we able to write all the fields to update
           //take all parameters to update
           //or read which fields want to update store in the array
           //iterate the array and set that vehicle properties
           String colorname=scanner.next();
           vehicle.setColor(colorname);
           System.out.println("the given vehicle color changed");
           count++;
           }
          
       }
       if(count==0)
       {
           System.out.println("the vehicle not found for change the color");
       }
      
   }
}