Just having a hard time adding a certain bit of given code to add an extra check to a preexisting method.
public boolean makeAppointment(int time,
Appointment appointment)
{
if(validTime(time)) {
int startTime = time - START_OF_DAY;
if(appointments[startTime] == null) {
int duration = appointment.getDuration();
// Fill in all the slots for the full duration
// of the appointment.
for(int i = 0; i < duration; i++) {
appointments[startTime + i] = appointment;
}
return true;
}
else {
return false;
}
}
else {
return false;
}
}
Is the main makeAppointment method. I need to add a method that checks if one appoints duration overlaps that of another. If I have two appointments: 1 is at 5PM and lasts 2 hours, the other is at 6 PM and only last one hour. I need to add the following method into this preexisting code to prevent this from happening.
private boolean checkMultihourAppointment(int startTime, int duration){
Thats the header for it. I have tried to implement it, but it ends up failing every Junit test.
Need any more info, please ask 🙂
Is this what you want? Rewrite your existing code to add checkmethod.