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

I have this code and im wondering if there is a way to get the variables from th

ID: 3569176 • Letter: I

Question

I have this code and im wondering if there is a way to get the variables from the Car class.

public class Car
{
private String name;
private String make;
private String color;
private double listPrice;
private double priceSold;
private double commission;
private int year;
private double mileage;
  
public Car(String name, String make, String color, double listPrice,
double priceSold, double commission, int year, double mileage) { //Constructor
super(); //calls constructor
this.name = name; //reference to name
this.make = make; //reference to make
this.color = color; //refrernce to color
this.listPrice = listPrice; //reference to listPrice
this.priceSold = priceSold; //reference to priceSold
this.commission = commission; //reference to commision
this.year = year; //reference to year
this.mileage = mileage; //reference to mileage
}
  
public String getName() { //string get name
return name; //return
}
  
public void setName(String name) { //set name
this.name = name; //reference
}
  
public String getMake() { //string get make
return make; //return
}
  
public void setMake(String make) { //get make
this.make = make; //reference
}
  
public String getColor() { //string get color
return color; //return
}
  
public void setColor(String color) { //set color
this.color = color; //reference
}
  
public double getListPrice() { //get list price
return listPrice; //return
}
  
public void setListPrice(double listPrice) { //set list price
this.listPrice = listPrice; //reference
}
  
public double getPriceSold() { //get sold price
return priceSold; //return
}
  
public void setPriceSold(double priceSold) { //set sold price
this.priceSold = priceSold; //reference
}
  
public double getCommission() { //get commision
return commission; //return
}
  
public void setCommission(double commission) { //set commision
this.commission = commission; //reference
}
  
public int getYear() { //get year
return year; //return
}
  
public void setYear(int year) { //set year
this.year = year; //reference
}
  
public double getMileage() { //get mileage
return mileage; //return
}
  
public void setMileage(double mileage) { //set mileage
this.mileage = mileage; //reference
}
  
@Override
public String toString() {
return "Car [name=" + name + ", make=" + make + ", color=" + color
+ ", listPrice=" + listPrice + ", priceSold=" + priceSold
+ ", commission=" + commission + ", year=" + year
+ ", mileage=" + mileage + "]";
}
}//end class

public class CarNode
{
CarNode next;
Car car;
  
public CarNode(Car _car)
{
next = null;
car = _car;
}
  
public CarNode(Car _car, CarNode _next)
{
next = _next;
car= _car;
}
  
public CarNode getNext() { //get next
return next; //return
}
  
public void setNext(CarNode next) { //set Next
this.next = next; //reference
}
  
public Car getCar() { //gets car
return car; //return car
}
  
public void setCar(Car car) { //set car
this.car = car; //reference
}
}//end main

public class CarLinkedList
{
private CarNode start;
private int listCount;
public CarLinkedList(CarNode carNode) //constructor
{
start = carNode;
listCount = 1;
}
  
public CarLinkedList() //constructor
{
start = null;
listCount = 0;
}
  
public void add(Car car) //add
{
if(start==null)
{
start=new CarNode(car); //new car
return;
}//end if
CarNode current = start;
CarNode temp=new CarNode(car);
while(current.getNext() != null)
{
current = current.getNext();
}//end while
current.setNext(temp);
listCount++;
}
  
public boolean remove(int index) //remove
{
if(index < 1 || index > size())
return false;
CarNode current = start;
for(int i = 1; i < index; i++)
{
if(current.getNext() == null)
return false;
  
current = current.getNext();
}//end if
current.setNext(current.getNext().getNext());
listCount--;
return true;
}
  
public int size() // size
{
return listCount; //return
}
  
public void display() //display
{
CarNode current = start;
while(current != null)
{
System.out.println(current.getCar().toString());
current = current.getNext();
}//end while
}//end main   
}//end class

Explanation / Answer

Create a object of CarLinkedList(with all the arguments details of the car) so that u can initalize them in linked llist