aspose file tools
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 The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "4 classes including Date and Time" Watch "4 classes including Date and Time" New topic

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:
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?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24189

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]
Have you tried LearnNowOnline?
subject: 4 classes including Date and Time