Forums Register Login

4 classes including Date and Time

+Pie Number of slices to send: Send
I am developing a AppointmentCalender as an assignment, part of the assignment was to write our own versions of the Date and Time class. I did this but I am confused as to whether I import the Date and Time classes or if I extend them. If I extend them how to I extend them within this hierarchy:
Date
Time
Appointment
AppointmentCalendar
Do I say
Public class Appointment extends Date, Time
Public class AppointmentCalender extends Appointment
I am not sure if you can or want to extend two classes?
Gerald
+Pie Number of slices to send: Send
A class can only extend one other class.
If the assignment is to "write your own versions" of Date and Time (there really isn't a Time class, anyway; there's java.sql.Time, but this is actually just a trivial subclass of Date) then I suspect the professor wants you to, indeed, write your own versions -- not subclass the existing one(s).
Regarding whether AppointmentCalendar should extend Appointment: ask yourself "Is an AppointmentCalendar a kind of Appointment?" If the answer is "yes" then it's appropriate to have AppointmentCalendar extend Appointment. If the answer is "no", then it's not, simple as that.
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 703 times.
Similar Threads
boolean remove(Appointment appt)
Help with printing appointments
appointment find (Date d, time t)
Nullpointer exception in servlet
"has a"
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:26:22.