Consider a scenario in which a university allows lecturers to borrow equipment. The equipment is available for use 5 days a week and for 7 periods during each day. When the equipment is booked for...

Consider a scenario in which a university allows lecturers to borrow equipment. The equipment is available for use 5 days a week and for 7 periods during each day. When the equipment is booked for use, the details of the booking (room number and lecturer name) are recorded. When no booking is recorded, the equipment is available for use. (a) Create a Booking class defined in the UML diagram below: (b) Now a TimeTable class is defined to process these bookings. Its UML diagram is given below: As you can see, the attribute of this class is a two-dimensional array of Booking objects. The methods of this class are defined below: +TimeTable(int, int) A constructor that accepts the number of days per week and number of periods per day and sizes the timetable accordingly. You should note that initially all elements in the array will of course have a null value—a null value will represent an empty slot. +makeBooking(int, int, Booking) : boolean Accepts the booking details for a particular day and period and, as long as this slot is not previously booked and the day and period numbers are valid, updates the timetable accordingly. Returns true if the booking was recorded successfully and false if not. +cancelBooking(int, int) : boolean Cancels the booking details for a particular day and period. Returns false if the given slot was not previously booked or the day and period number are invalid, and true if the slot was cancelled successfully. +isFree(int, int) : boolean Accepts a day and period number and returns true if the day and period numbers are valid and the given slot is free, and false otherwise. +getBooking(int, int) : Booking Accepts a day and period number and returns the booking for the given slot if the day and period number are valid and the slot has been booked or null otherwise. +numberOfDays() : int Returns the number of days associated with this timetable. +numberOfPeriods() : int Returns the number of periods associated with this timetable. Implement this class in Java. (c) Write a suitable tester for this class. Below is a UML diagram for an inheritance relationship between two classes— Vehicle and SecondHandVehicle. (a) By referring to the diagram, explain the meaning of the term inheritance. (b) What do you think might be the function of each of the constructors? (c) What do you think might be the reason for the fact that in the Vehicle class there is a set-method for the value attribute, but not for the other three? (d) Write the header for the SecondHandVehicle class.
May 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here