aspose file tools*
The moose likes Cattle Drive and the fly likes OOP-4 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 "Lookup" : I would like some clarification" Watch "OOP-4 "Lookup" : I would like some clarification" New topic
Author

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

Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1691
    
  12

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?



When you do things right, people won't be sure you've done anything at all.
paul wheaton
Trailboss

Joined: Dec 14, 1998
Posts: 20647
    ∞

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.


permaculture Wood Burning Stoves 2.0 - 4-DVD set
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1691
    
  12

Thanks
Salavat Mu
Greenhorn

Joined: Sep 25, 2010
Posts: 5
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

Joined: Jul 22, 2000
Posts: 9047
    
  10
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.

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Salavat Mu
Greenhorn

Joined: Sep 25, 2010
Posts: 5
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

Joined: Jul 22, 2000
Posts: 9047
    
  10
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

Joined: Sep 25, 2010
Posts: 5
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

Joined: Mar 15, 2001
Posts: 1197
submit your code and find out!
Salavat Mu
Greenhorn

Joined: Sep 25, 2010
Posts: 5
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

Joined: Oct 23, 2009
Posts: 161

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


star chaser..
Salavat Mu
Greenhorn

Joined: Sep 25, 2010
Posts: 5
Thanks Gary..
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: OOP-4 "Lookup" : I would like some clarification