File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

4 classes including Date and Time

 
Gerald Spica
Ranch Hand
Posts: 30
  • 0
  • 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: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic