Question: I have a method in a Helper class that is as follows: public int addReservation(Reservation aReservation) { int i = 0; int returnCode=1; //add code

I have a method in a Helper class that is as follows:

public int addReservation(Reservation aReservation)

{

int i = 0;

int returnCode=1;

//add code here:

if(reservationList.size() > 0)

{

while(returnCode == 1)

{

if(aReservation.getReservationDateTime().getTime() < reservationList.get(i).getReservationDateTime().getTime())

{

reservationList.add(i, aReservation);

returnCode = 0;

}

}

}

else

{

reservationList.add(aReservation);

returnCode = 0;

}

return returnCode;

}

reservationList is a linkedList. Whenever I try to add a reservation in the program, it appears that the reservation is not found. How can I resolve this issue?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!