I am stuck I do not understand one of the nitpicks I got. The basic logic behind my program is to except a serial number as a command line argument then retrieve the description from the HashMap using the serial number. After retrieving the description I use an if/else construct to instantiated the desired object based on the passed in serial number. I use the follow basic setup for object creation:
where each Child class extends AbstractParentClass and overrides an AbstractParentClass's method. Is the if/else stuff wrong? Am I not doing polymorphism? The object created is not known until runtime and I have followed the examples in the books, so I was under the impression I was doing polymorphism. I looked at putting the different objects in an array, but didn't see the point in it. Or am I just missing the point of the remark (nitpick) all together. I can already hear myself saying "duh!" and leaving a red mark on my forehead
[This message has been edited by Richard Boren (edited June 28, 2001).]
Hey Richard, I have not been nitpicked for this one yet but I will try to guide you. First of all I have four classes for this prog besides Lookup. All Lookup does is create static hashmap that contains a dozen things to rent, meaning a couple of videos, pieces of furniture, and some books on tape. I created 12 of these objects using their particuliar class (Video class for videos and so on). That way all my Lookup in main has to do is see if the serialnumber taken in is in the hashmap and if it is just print the description using the method getDescription for the object from the hashmap. My main in lookup only contains about 16 lines. I hope I am not giving away too much. HTH JDJ, Just erase anything if you think it is too much. I went ahead and deleted a line because I thought it gave away a little much. [This message has been edited by Amber Woods (edited June 28, 2001).]
"Happiness is a way to Travel, <b>Not</b> a Destination" -- Unknown
Over looking puting the objects in the HashMap was my major down fall. Now that Amber's got me back on track I think I'll be able to finish the assignment. I was following the examples in the books a little to closely. I was blinded by the knowledge Hey this is a big step for me. And boy does my forehead hurt "DUH!!!". Thanks Amber and Michael. Do you think I should delete this thread?
First off all I dont have a problem with anything posted here. I will however ask Paul to check, to be on the safe side. Secondly Richard I did exactly the same and Marilyn nitpicked me towards the solution. Must say she did take her time doing it though, what Amber & Micheal said in one posting she did in 3 or 4 nitpicks . But man the feeling when I finally saw it. It was my OO moment !!! Good luck Richard
I just finished Lookup, and I have to say that this has been the most fun program(s) so far. I did the same thing as Amber and Michael. I am looking forward to getting nitpicked on it. I guess its time to start looking for a good book on Servlets. Matthew Phillips
To Matthew and others working ahead. The example in the assigment of servlets is good for Servlets 1. So that does not nead a book. The challange comes with Servlets 4b it is something like 'Say' and without some help of a book it will be rather tough. Probably the Api-doc of servlets should suffice you should look for e.g. servlet-2_3-pfd2-docs.zip see http://java.sun.com/products/servlet/download.html And to OO-4. The figure in the Assigment for OO-4 should give you a (the) good hint!
[This message has been edited by Peter Gragert (edited June 29, 2001).]
I've been asked to take a look at this thread. I remember this submission. Marilyn passed it on to me and asked me to comment on it. So the offending nitpick is mine. One of the purposes of this assignment is to introduce polymorphism. My impression was that there was no polymorphism being used in the submission.