Two ways to clock in — plus a brand new Hotel class with derived getters | Workbook p.45-46
You already wrote punchIn(int time) and punchOut(int time) in the last exercise. Sometimes, though, an employee just wants to punch the clock right now — not pass an integer. Add overloaded versions with no parameters that figure out the time using LocalDateTime.now(). After this step, Employee should have four punch methods: two with a time argument and two without.
Then build a brand new Hotel class. A hotel knows its name, how many suites and basic rooms it has, and how many of each are currently booked. The booked counts have no public setters — the only way they change is through bookRoom(...). The two getters for available rooms don't store anything; they calculate the answer from total minus booked. That is a derived getter.
You also need two overloaded constructors: one for a brand-new hotel where booked counts default to zero, and one for an existing hotel where you want to set every value yourself.
LocalDateTime.now() — no input parameter.
LocalDateTime.now() internally. The most common case — punching the clock right now.Both methods share the same name. Java picks the right one by looking at the arguments. That's method overloading.
bookedSuites and bookedBasicRooms default to 0.
Same class name, different parameter lists — constructor overloading. Java picks the right one by counting the arguments.
getAvailableSuites() should not store its answer anywhere. It computes it: numberOfSuites - bookedSuites. Same for getAvailableRooms(). This is exactly the pattern from Visual #3 — the truth lives in the booked count, and "available" is always a fresh calculation.
Workbook 4a, p.45-46 — Module 2, Exercise 3: hotel-operations (Overload Methods)