This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes 4 classes including Date and Time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "4 classes including Date and Time" Watch "4 classes including Date and Time" New topic
Author

4 classes including Date and Time

Gerald Spica
Ranch Hand

Joined: Jul 28, 2003
Posts: 30
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

Joined: Jul 08, 2003
Posts: 24183
    
  34

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.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 4 classes including Date and Time
 
Similar Threads
Nullpointer exception in servlet
boolean remove(Appointment appt)
appointment find (Date d, time t)
Help with printing appointments
"has a"