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

Introduction In this assignment the student will make a simple database for a ca

ID: 3760361 • Letter: I

Question

Introduction

In this assignment the student will make a simple database for a car dealership. The user will be able to add cars, delete cars, search for cars with certain characteristics, and display results clearly. In this assignment the student will design several classes, using one file per class.

Procedure

For this assignment the following classes are required:

Car    implements Comparable Cloneable

    Has private String fields for model, color, int year, int vin number and double price.

    Has a default constructor (a forklist or go-cart) and has a 5 parameter constructor.

    Has a toString() method which returns the model and year for example.

    Has a compareTo() method based on model name.

    Has a clone method.

CarLot

    Must have at least two for loops and two iterators.

   Has static methods taking a LinkedList input to:

        1 - display all the cars in alphabetical order with headings, one line per car. (Collections.sort(x))

        2 - display the car info given a vin number

        3 - list the first two cars of the same model (use compareTo)

        4 - update inventory (add, delete and modify a car). Implement the code for one and display only a message for the other two.

        5 - display the total value of cars in the lot.

        6 - shallow clone the list. (documentation will describe it)

        7 - deep clone the list. (documentation will describe it)

Note: these methods will use only the linked list data structures.

UseCarLot      // The test cases!

   All methods in the CarLot class to be verified with output.

    You can hard code a few cars and add to a linked list. Pass this list to the CarLot class when ready.

    You may want to add additional setters and getters to enable adequate testing of the cars in CarLot.

    A for loop to allow additional inputs for testing can be used, and will have a termination mechanism.

    Sufficient valid data testing and sufficient invalid data testing will be done to ensure correct operation. This will be documented as usual.

    The clone tests will be create the clone ;test sameness; modify data(modify one car?, add one car?); test for cloneness

Menu         // You decide how to implement the menu concept to do something like this.

   Prompts the user with a choice of actions. The actions are the seven methods of CarLot plus exit.

    Returns the choice (char?, int?) back to main for execution.

   Suggest using a Singleton class -> public static final

    Appropriate action forwarded to CarLot object for execution.

    When you add the IO.java class, DO NOT copy the file into your carlot folder. Add an existing copy of the file to the project and add the appropriate directory path to the CLASSPATH variable.

Explanation / Answer

import java.util.*;
public class Car implements Comparable<car>, Cloneable
{
private String model;
private String color;
private int year;
private int vin_number;
private double price;
public Car()
{
}
public Car(String model, String color, int year, int vin_number, double price)
{
this.model = model;
this.color = color;
this.year = year;
this.vin_number = vin_number;
this.price = price;
}
public Object clone()
{
try
{
return super.clone();
}
catch (CloneNotSupportedException e)
{
return null;
}
}
public String getModel()
{
return model;
}
public String getColor()
{
return color;
}
public int getYear()
{
return year;
}
public int getVinNumber()
{
return vin_number;
}
public double getPrice()
{
return price;
}
public void setModel(String newModel)
{
model = newModel;
}
public void setColor(String newColor)
{
color = newColor;
}
public void setYear(int newYear)
{
year = newYear;
}
public void setVinNumber(int newVinNumber)
{
vin_number = newVinNumber;
}
public void setPrice(double newPrice)
{
price = newPrice;
}
public String toString()
{
return "Model: " + model + " Color: " + color + " Year: " + year + " Vin Number: " + vin_number + " Price: " + price;
}
public int compareTo(Car o)
{
if(this.getModel().compareTo(car.getModel()))
return 1;
if(car.getModel().compareTo(this.getModel()))
return -1;
else
{
return 0;
}
}
public static void main(String [] args)
{

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote