• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OOP-4 "Lookup" : I would like some clarification

 
Janeice DelVecchio
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. I understand the assignment itself, and all the parts of it. But I don't feel like the assignment was very specific:

Should these classes be inner classes or should I make separate files for each?
Should I override the default constructors?
Should I create getter and setter methods for the attributes?

 
paul wheaton
Trailboss
Pie
Posts: 21595
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They should all be inner classes.

Should I override the default constructors?


Do the simplest thing that could possibly work.

Should I create getter and setter methods for the attributes?


Do the simplest thing that could possibly work.

 
Janeice DelVecchio
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
Salavat Mu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ! didnt want to create new topic? the name is same, lookup qstn... Is my thought right? i create hashmap where "key" (is the serial #) and the "value" (is an item string-description)? then in i read the input serial # and using getDescription() show its value?

by the way, this my first qstn on this forum
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Salavat.

Welcome to JavaRanch.

You don't need or want a HashMap for this assignment. You want to pass in the serial number on the command line and use that to get the description from the Object. The "value" is a String, but you are using OOP rather than a HashMap to get that result.

Notice that you will create an abstract class to accomplish this.
 
Salavat Mu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for helping!
1) Ive 3 classes from abstract Thing, each containig getDescription() , thats ok...
2) Ive Hashmap with "key= serial #" and "value = class name ex. Furniture"
3) Then i read from console The serial #, and depending what value it matches in Hashmap (example Video) i invoke Video.getDescription() which describes in String what a class about..

I miss smth, cause it said to be a description of an item, and i stil dont get where to put such a description.
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Salavat Mu wrote:I miss smth, cause it said to be a description of an item, and i stil dont get where to put such a description.


I'm not sure what a "smth" is, but the String description of the item is in the item (Object) that you created. In other words, the Furniture class contains a String which is a description of a piece of Furniture. The getDescription() method gets (returns) that description when the Lookup class calls that method on the Object you instantiated.
 
Salavat Mu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thanks now each of my classes (deriver from Thing) contain string description, then i read serial from keyboard, using if statement if Value of Hashmap matches (serial# (key) and class (value) ex.Furniture), new Furniture instance (with string description) is created and getDescription() is invoked. But still not sure if I done the needed way...
 
Carol Murphy
village idiot
Bartender
Posts: 1203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
submit your code and find out!
 
Salavat Mu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carol Murphy wrote:submit your code and find out!
Looked for topics with submition, not sure where i send mine.. please tell where to send, thanks
 
Gary Ba
Ranch Hand
Posts: 161
Firefox Browser Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you sign up for Cattle Drive? Who did you send your last assignment to? It should be the same nitpicker per group of assignments. If not, look at the cattle drive page and read about the requirements.

Hope this helps,
Gary
 
Salavat Mu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Gary..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic