• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

OOP-4 clarification

 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
I can't take it! You are too smart for me! Here is the tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic