• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

4 classes including Date and Time

 
Gerald Spica
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic