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

I have written all of my code required for the three classes described below, bu

ID: 3600083 • Letter: I

Question

I have written all of my code required for the three classes described below, but I cannot make the three classes work together. I believe there are some errors in my code, so if you could scan through it and possibly bring it up to working order it would be greatly appreciated. I realize this question is very lengthy, but it is due only to me wanting to provide the most amount of information and because I have supplied the code I have written for my three classes. I would really appreciate any help!!

Below are the requirements and a UML of how the project fits together…disregard any GUI stuff I will do that on my own

CarDataNode is a doubly linked list node

It must implement addNodeAfter and toString in a fashion similar to the Book’s ADT/Class Demo Code

removeNode removes the calling node from the list!

checkIn is used to set the Date checkIn to the current time

checkOut is used to set the Date checkOut to the current time

equals is only concerned with checking if the license plates between two nodes are the same

Two static methods are specified

Finding a node with a given license plate – takes two arguments, a node to start searching at and the string

Getting a node with a given index – takes two arguments, a node to start searching at and the index of the node to return

Should be serializable!

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)

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

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()

GarageExitBag

Should only have a head, not a tail

Nodes that are removed from the GarageSet should be added to the GarageExitBag

The method, dumpOutputFile, should print the contents of the exit bag to a text file named using the current date. I used SimpleDateFormat outFileFormat = new SimpleDateFormat("'GarageDump'E_yyyy_MM_ddhh_mm_ss"); as the SimpleDateFormat object, then got the file name with outFileFormat.format((new Date())) + ".txt".

General details

When the application exits using the Exit option in the File menu, GarageSet should be saved and the GarageExitBag should be dumped

I suggest doing more research on SimpleDateFormat and closing frames without ending the program, but this is left to you to do a bit of research on to figure out

I will provide a sample GEB text dump output from running the program once – emulate it, but your format does not have to strictly match it

I use selfReference in my JFrames as a pointer to ‘this’, so I can call the frame’s functions inside of ActionListeners as needed

I do not require you to check to see if the license plate is “correct” – “Baccon” could well be an LPN

You need not display error messages if a car cannot be added (due to duplicates) or removed (due to not existing). You may choose to, though, and may get more ‘code style’ points as a result!

CarDataNode Class:

import java.io.Serializable;

import java.util.ArrayList;

import java.util.Date;

import java.util.List;

public class CarDataNode {

        private long serialVersionUID;

        private String licensePlateNumber;

        private Date checkIn;

        private Date checkOut;

       

        public CarDataNode(String cdn){

                licensePlateNumber = cdn;

                checkIn = new Date();

                checkOut = new Date();

        }

       

       

        public String getLPN(){

                return licensePlateNumber;

}

        public CarDataNode getNext(){

                CarDataNode cdn = new CarDataNode("");

                return cdn;

        }

       

        public void checkIn(){

                checkIn = new Date();

        }

       

        public void checkOut(){

                checkOut = new Date();

        }

       

        public Date getCheckIn(){

                return checkIn;

        }

       

        public Date getCheckOut(){

                return checkOut;

        }

       

        public void addNodeAfter(CarDataNode addCar){

               

                //iterate for loop through LinkedList

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

                       

                        //check position of the given node by using equals

                        if(cdnList.get(i).equals(addCar)){

                               

                                //create new Node and add it to list at

                                //next index

                                CarDataNode addCarNext = new CarDataNode("");

                                cdnList.add(i+1, addCarNext);}}}

        public void removeNodeAfter(CarDataNode reCar){

                //iterate through loop through linked list

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

                       

                        //check position of node

                        if(cdnList.get(i).equals(reCar)){

                               

                                cdnList.remove(i);

                                }}}

        public boolean equals(CarDataNode eqCar){

                if(this.licensePlateNumber.equals(eqCar.licensePlateNumber)){

                        return true;

                }

                else

                        return false;

        }

       

       

        public static CarDataNode findNodeWData(CarDataNode cdn, int index){

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

                       

               

                if(cdnList.get(i).equals(cdn)){

                       

                        if(cdnList.get(i).licensePlateNumber.equals(lpn)){

                                return cdnList.get(i);

                        }

                }

        }

                return null;

        }

       

        public static CarDataNode getNodeAtIndex(CarDataNode cdn, int index){

               

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

                       

                        if(cdnList.get(i).equals(cdn)){

                                if(i > index){

                                        return null;

                                }

                                else{                                   return cdnList.get(index);

                        }}}}}  

GarageSet Class:

import java.util.LinkedList;

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 < list.size(); i++)

              {

                     carToCheckout = list.get(i);

                     if (carToCheckout.equals(carName))

                     {

                           list.remove(carName);

                           break;

                     }

return;

              }

              return carToCheckout;

       }

       // method 5

       public static GarageSet loadGSData()

       {

              GarageSet gs = new GarageSet();

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

              {

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

              }

              return gs;

       }

       @Override

       public String toString()

       {

              return (gs + " ");

       }

       // method 6

       public static void saveGSData(GarageSet garageSet)

       {

              GarageSet gs = garageSet;

       }

GarageExitBag:

import java.io.BufferedWriter;

import java.io.FileWriter;

import java.io.IOException;

import java.text.SimpleDateFormat;

import java.util.Date;

public class GarageExitBag {

private CarDataNode head;

public GarageExitBag() {

this.head = null;

}

public void addNodeToBag(CarDataNode node) {

CarDataNode temp = head;

CarDataNode prev = head;

if (head == null) {

head = node;

} else {

while (temp != null) {

prev = temp;

temp = temp.getNext();

}

prev.setNext(node);

}

}

public void dumpOutputFile() {

SimpleDateFormat format = new SimpleDateFormat("yyyy_MM_dd_hh_mm_ss");

try {

BufferedWriter writer = new BufferedWriter(

new FileWriter("GarageDump" + format.format(new Date()) + ".txt"));

CarDataNode temp = head;

while(temp!=null) {

writer.write(temp.toString()+" ");

temp = temp.getNext();

}

writer.close();

} catch (IOException e) {

// TODO Auto-generated ctch block

e.printStackTrace();

}

}

}

Explanation / Answer

import java.io.Serializable;

import java.util.ArrayList;

import java.util.Date;

import java.util.List;

public class CarDataNode {

        private long serialVersionUID;

        private String licensePlateNumber;

        private Date checkIn;

        private Date checkOut;

       

        public CarDataNode(String cdn){

                licensePlateNumber = cdn;

                checkIn = new Date();

                checkOut = new Date();

        }

       

       

        public String getLPN(){

                return licensePlateNumber;

}

        public CarDataNode getNext(){

                CarDataNode cdn = new CarDataNode("");

                return cdn;

        }

       

        public void checkIn(){

                checkIn = new Date();

        }

       

        public void checkOut(){

                checkOut = new Date();

        }

       

        public Date getCheckIn(){

                return checkIn;

        }

       

        public Date getCheckOut(){

                return checkOut;

        }

       

        public void addNodeAfter(CarDataNode addCar){

               

                //iterate for loop through LinkedList

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

                       

                        //check position of the given node by using equals

                        if(cdnList.get(i).equals(addCar)){

                               

                                //create new Node and add it to list at

                                //next index

                                CarDataNode addCarNext = new CarDataNode("");

                                cdnList.add(i+1, addCarNext);}}}

        public void removeNodeAfter(CarDataNode reCar){

                //iterate through loop through linked list

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

                       

                        //check position of node

                        if(cdnList.get(i).equals(reCar)){

                               

                                cdnList.remove(i);

                                }}}

        public boolean equals(CarDataNode eqCar){

                if(this.licensePlateNumber.equals(eqCar.licensePlateNumber)){

                        return true;

                }

                else

                        return false;

        }