Question: Assume that the classes listed in the Java Quick Reference have been imported where approp Assume that the classes listed in the Java Quick Reference
Assume that the classes listed in the Java Quick Reference have been imported where approp
Assume that the classes listed in the Java Quick Reference have been imported where appropriate. Unless othervise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied.
This question involves the AppointmentBook class, which provides methods for students to schedule appointments with their teacher. Appointments can be scheduled during one The AppointmentBook class contains two helper methods, isMinuteFree and reserveBlock. You will write two additional methods of the AppointmentBook class. public class AppointmentBook
public class AppointmentBook
Returns true if minute in period is available for an appointment and returns false otherwise Preconditions: c period ; minute
Marks the block of minutes that starts at startMinute in period and is duration minutes long as reserved for an appointment
is duration minutes long as reserved for an appointment Preconditions: period ; startMinute ; duration
private void reserveBlockint period, int startMinute, int duration implementation not shown
Searches for the first block of duration free minutes during period, as described in part a Returns the first minute in the block if such a block is found or returns if no such block is found.
such block is found. Preconditions: period ; duration
public int findFreeBlockint period, int duration to be implemented in part a
Searches periods from startPeriod to endPeriod, inclusive, for a block of duration free minutes, as described in part b If such a block is found, calls reserveBlock to reserve the block of minutes and returns true; otherwise
returns false. Preconditions: startPeriod endPeriod ; duration
There may be instance variables, constructors, and methods that are not shown.
Consider the following list of unavailable and available minutes in period
The method call findFreeBlock would return to indicate that a minute block starting with minute is available. No steps should be taken as a result of the call to findF reeBlock to mark those minutes as unavalable
The method call findFreeBlock would return since no minute
Searches for the first block of duration free minutes during period, as described in such block is found.
blic int findFreeblock int perion ; duration
B
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
