The following is in preparation for the Lookup assignment. I have created the Lookup.java file - it compiles. I have created four support classes - they compile. They are merely the basics to get started filling in with appropriate coding to accomplish the assignment.
The other two support classes are copy / paste duplicates of Video.java just the names changed according to requirements of the assignment. The problem is the Furniture and BookOnTape classes are accepted when instanced in the Lookup.java file but the Video instance gives this error:
All of the support classes are in the same package "rental" with the same format, etc. So what is wrong with this picture? doco
eeeewwwww wwwweeeeee!!! Look at all that free code Martha! I have a printout of the requirements for that assignment on my desk as I was about to start working on it myself. I copied your code and created just the two files in the same directory. I removed the import statement for rental in Lookup and didn't include any package information in Video.java, afterwards I created the abstract class for Thing.java, compiled and ran Lookup and everything worked fine the way you have it, so the error must be related to Marilyn's suggestion or something is messed up with the package statements / file placements. Don't know that I would of added all that package information to the assignment. [ April 16, 2003: Message edited by: John Hembree ]
Donald R. Cossitt
Joined: Jan 31, 2003
Other than the package thingy, what was shown was just about verbatum in the assignment. So, I am not sure I let too much of a cat out of the bag. At any rate, I was merely experimenting with the package thingy and very curious as to why it didn't work. 1. The rental directory is the only place the class files were / are. 2. Everything compiles nicely if I move the class files to the same directory as the Lookup.java file. 3. Classpath variables are sufficient. Or at least enough that the compiler does not complain that "package rental does not exist - import rental.*;"
Now I am left with the same dillema whether or not I use this for the assignment or not. Suggestions? Be gentle John . Thanks doco
If you don't add public to the constructor, then only classes in the same package, or subclasses of that class, will be able to instantiate an object of that type. When you don't supply an access modifier (public, private, protected), then the default is considered "package", which is somewhat misleading since subclasses, even those in different packages, also have access. It's pretty much a good practice to label your constructors public unless you have specific reasoning not to. For example, Singletons most often use a private constructor and a static access method. That way, only that class can actually instantiate itself. Explains why with John's changes, the errors don't occur. Good catch there
Am I allowed to re-use the text file feature from SortNames to store my video, audio, furniture object information in text files rather than embedding the info in Lookup.java? No doubt, it's overkill, but I do that a lot.
Donald R. Cossitt
Joined: Jan 31, 2003
Thanks John & Jason.
John mused: =========== Am I allowed to re-use the text file feature from SortNames to store my video, audio, furniture object information in text files rather than embedding the info in Lookup.java?
Yeah, what John said. This actually makes better sense to me than an embedded HashMap - Course there are a lot of things I don't know; really, it's true! :roll: doco
Chicken Farmer ()
Joined: May 08, 2001
Well, it gives the nitpicker more to go over, and that is usually frowned upon, but I think I'll defer to Marilyn's opinion on this matter.
Marilyn de Queiroz
Joined: Jul 22, 2000
Seems like the assignment requires a HashMap containing a dozen things to rent.
It's the part in the requirements section that says
Give each of your classes relevant attributes
To me that seems relative to an individual's perspective. Of course the instructor's solution is 120 lines so I could calculate it backwards and try to figure out how many attributes could span the three data types and then divide them accordingly. However if this is Say-4b of OOP, then I would hope for a little tolerance in code re-use and implementation of some of the logic learned to date. I like Marilyn's answer myself... nice and vague.
Originally posted by Barry Gaunt: Don't forget the nitpicker only has to say "nope" and that takes 0.2 seconds to type. But for you it could mean an hour's undoing what you thought was cool... (I know, been there, done that... )
It was at least an hour of undoing probably more..
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com