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?
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
Joined: Sep 25, 2010
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
Joined: Jul 22, 2000
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.
Joined: Sep 25, 2010
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...
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.