Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help understanding OOP-4 Lookup Rules.  RSS feed

 
Rob Mihalko
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey  I just joined the Cattle Drive and have been diligently working at completing the tasks.  I have experience in Visual Basic but no prior study in Java.  This is a rush of new information but I think I am going through at a reasonable pace and this forum is a great help.

My question is about the OOP-4 Lookup assignment. 

I do not know what I am supposed to be doing.  I read about polymorphism and I understand the concept. I also understand the image showing inheritance. 

What I do not understand is what I am supposed to be doing.  No idea what the goal is.  Can anyone explain the task a bit more clearly to me?  I would really appreciate it.
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write a program called Lookup that takes in a serial number and writes information on a given item to the console.

So that's the goal.  I don't know how much I should be giving away in terms of coding, but think about how you would implement just this.  You'd probably use a Map with a String for the serial number and a String for the description.
You will need to make an abstract class called Thing and three subclasses: Video, BookOnTape and Furniture. There will be an abstract method called getDescription() that returns a String.

So now you know the structure of the classes.  You will still use a Map with a String for the serial number, but the description now come from some place else.  What is the Map going to look like now?
 
Rob Mihalko
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can see that, but...

I might be missing something here, but from what I can tell the map stores a "number" and a description... You want to give a number and get the description... Whats the point of all the other classes? The description is in the map.   I might be dense but this just sounds like a simple one class kind of problem with a hashmap...  It says we should keep it simple to solve the problem so I am lost as to what all the complexity is for.

  I don't know how much I should be giving away in terms of coding,


That being said.. I understand if you cannot give away any more information than you already have.  I might figure it out eventually or just skip it.
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But what if the description wasn't in the map, only the reference to an object?  And what if you had a bunch of different classes but all had a similar interface or method?
 
Rob Mihalko
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. I think I get you... A lot more clear.  I'll give it a try.  Thank you for your help.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!