File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Cattle Drive and the fly likes OOP-4 clarification Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "OOP-4 clarification" Watch "OOP-4 clarification" New topic

OOP-4 clarification

Sam Tilley
Ranch Hand

Joined: Dec 05, 2001
Posts: 160
To sort out my final bits of OOP-4.
I have created my different classes as expected and passed in my hashmap object but the question asks for info on each picked video/bookOnTape. To do this i have set up a class constructor and if/else's for each item but this has created 12 if/elses in the three subclasses and has left my code at well over 170 lines in total, well over the instructors 120 lines.
Am i supposed to to individual item info or just generic class info using constructors??
Thanks for any enlightenment

Sam Tilley SCJP, SCWCD
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
The key lesson here is polymorphism. Your program doesn't need to know the actual type of each video/book on tape because they know what type they are when they are instantiated. The program just needs to know the common relationship they share. I hope that doesn't give away too much.

Matthew Phillips
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
In addition to what Matt said, look at the UML diagram associated with the assignment. Believe it or not, it explains exactly what your program should look like, and how to utilize the classes in the way Matt stated (which I think was a perfectly valid hint).
I agree. Here's the link:
subject: OOP-4 clarification
jQuery in Action, 3rd edition