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

Need help writing GarageSet class... you will notice that this class uses a CarD

ID: 3598965 • Letter: N

Question

Need help writing GarageSet class...you will notice that this class uses a CarDataNode class, I have already written this code for the CarDataNode class so please do not ask for it or comment that there isn't enough information. Just answer to UML specifications

GarageSet class specs and UML diagram are posted...

GarageSet UML

GarageSet

*Must at least have head. You may choose to add a tail

*Should be able to add Nodes (checkIn) and remove nodes (checkOut, using both a String and an index)

i.checkIn and checkOut are also responsible for ensuring the node’s checkIn/checkOut field update appropriately!

ii.Duplicates are not allowed in a set!

*GarageSet’s toString is to be used when displaying the GarageSet on the garage display frame

*GarageSet should be serializable and is responsible for saving itself/loading itself upon program start using the two static methods loadGSData() and saveGSData()

42

Explanation / Answer

The following is the code for the GarageSet Class. Some assumptions where made on the CarDataNode class for checkOut(string) function and places where CarDataNode class is used. Also saveGSData() functionality is not clear.

// Class Declaration

public class GarageSet implements java.io.Serializable

{

// Instance Variables

long serialVersionUID;

LinkedList<CarDataNode> list;

// Constructor Declaration of Class

public GarageSet()

{

list = new LinkedList<CarDataNode>();

}

// method 1

public CarDataNode getHeadNode()

{

return list.get(0);

}

// method 2

public void checkInCar(CarDataNode cardatanode)

{

list.add(cardatanode);

}

// method 3

public CarDataNode checkOutCar(int n)

{

CarDataNode carToCheckout = list.get(n);

list.remove(n);

return carToCheckout;

}

// method 4

public CarDataNode checkOutCar(String carName)

{

CarDataNode carToCheckout;

  

for (int i = 0; i < linkedList.size(); i++)

{

carToCheckout = linkedList.get(i);

if(carToCheckout.CarName == carName)

{

list.remove(n);

break;

}

}

  

return carToCheckout;

}

// method 5

public static GarageSet loadGSData()

{

GarageSet gs = new GarageSet();

  

for (int i = 1; i <= 10; i++)

{

gs.list.addBack(new CarDataNode(""));

}

return gs;

}

@Override

public String toString()

{

return(gs + " ");

}

// method 6

public static void saveGSData(GarageSet garageSet)

{

GarageSet gs = garageSet;

}

public static void main(String[] args)

{

GarageSet.loadGSData();

GarageSet..saveGSData();

}

}

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