This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OOP-4 clarification

 
Sam Tilley
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic