• Post Reply Bookmark Topic Watch Topic
  • New Topic

Abstract Class, Hashtables. (warning: long post)  RSS feed

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm supposed to do an assignment that is related to the topics above. However I'm not sure if I've used the above correctly (as in, correct logically). The program should do the following:

- User enters whether he is client or property agent.
user enters info.

- If is property agent, user can
1) add property list,
2) view property list,
3) remove property list,
4) list property list.

you can view my codes here:

Main:
I'm trying to add information here. However, I'm not able to save information for the subclass. (i.e. Property Agent's info)
I've tried creating new person.client() but there's error.

http://www.geocities.com/jbtang2002/Assignment1.java
http://www.geocities.com/jbtang2002/Console.java


Property: I'm supposed to calculate commission here, but stuck in it.
http://www.geocities.com/jbtang2002/Property.java
http://www.geocities.com/jbtang2002/House.java
http://www.geocities.com/jbtang2002/Apartment.java

http://www.geocities.com/jbtang2002/Person.java
http://www.geocities.com/jbtang2002/Client.java
http://www.geocities.com/jbtang2002/PropertyAgent.java
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jia Bin Tang:
Hi, I'm supposed to do an assignment that is related to the topics above. However I'm not sure if I've used the above correctly (as in, correct logically). The program should do the following:....

While some may make the effort to download and view your code, I'm betting that few (and likely none will). I don't know how to say this without being blunt, but you may be asking too much work from the volunteers here. I suggest that you read through the FAQs, especially the ones in "How To Ask Questions On Java Ranch". Also you would do well to learn how to create and post an SSCCE which you can read about here. If you read and study these links, and use the recommendations to help construct your next post, I'll bet you'll get a more informative and helpful response than mine. Good luck.
 
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Jia Bin Tang, Welcome to JavaRanch.
Unfortunately, the time to go through all your code will be long enough to reply to a number of posts in the forum.

Please follow Pete's suggestions and pin-point the actual problem in your code. We'll be more than happy to assist you and solve your problem.

Good Luck...!!!
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Other than the usual OO stuff, which is inconsistent with line 140 of Assignment1 which should read:

System.out.println("Sorry, invalid option. Please try again.");

instead of the variant spelling of banner sites - what I see here by contrasting your post title against the classic OO style in the code is that you should be advised: OO does not write code, you do.

Thus, to get you ( un-tracked in Redneck vernacular ) you new ( make one ) a Hashtable at line 100 of Assignment1 - but we do not do homework at Java Ranch. It makes it easier for me because that's fewer coders who make it to real jobs and therefore I have not as much competition, but they won't let me do it. Even then I am not going to:


At least they know who Cay S. Horstmann & Gary Cornell are so you may be able to read their books. Line 14-17 of PropertyAgent looks like you tried to write a constructor then commented it out. Property is abstract, then class House extends Property - this is what the concept abstract models ~ you have a concept, which you write as abstract because to be of some use, certain additional things have to be added. That class that extends house demonstrates the idea of abstract and how it is supposed to be used.

Everything goes to System.out or is read in from the same place (System.in) which is usually the keyboard. To examine "not able to save information" I notice first that Choice is syntax highlighted in my editor so that is probably is a word used by java for machine control and should be changed. To access sub-class / super-class do not create a new one as in:
new person.client() just use the one you already create on line 51 of Assignment1.java To calculate commission you will have to add a method to the Property Agent class, which I re-formatted to straighten it back our for you:

It will be faster for you to look at the code in the browser and make your changes while you are adding the calculate commision method. To write the calcualte commision method, you will have to know what you need the calcualte commision method to calculate.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!