aspose file tools*
The moose likes Beginning Java and the fly likes Please Help  I am lost!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Please Help  I am lost!!!" Watch "Please Help  I am lost!!!" New topic
Author

Please Help I am lost!!!

Nancy Bradley
Ranch Hand

Joined: Feb 25, 2004
Posts: 32
I have an assignment where I should write a Java abstract class which will be the base to calculate some points of a competition. The points are assign different depending on weather the person is a boy,girl,man or woman.
I wrote the abstract class and then a class for each one of the groups. When I tried to write the test I get error messages for each of the groups that says:
cannot resolve symbol
constructor Girl(java.lang. String, java.lang.String)
This piece is not finish yet, I just do not know what to do.
If anyone knows where I can find a good reading on abstract class that will be helpful too. I do not have the concept clear.
Any help will be gratly appreciated.
Thanks,
Nancy
This is the code I wrote:
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Assuming you know the type of object you will be dealing with at compile time, you could have something like this:
- an abstract Rewards class, with an abstract calculate method
- four implementations of this class, one for each type of person.
- an abstract class (or interface) Person
- four implementations of this class
If you have this you can write:

If you don't know which type of person you will be dealing with till run time, you'll need a factory class as well. The you can write:

All you need to remember about abstract classes is they are basically templates - they don't necessarily do anything, but they do force all subclasses to do something - in this case implement a calculate method.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Mathias Nilsson
Ranch Hand

Joined: Oct 13, 2003
Posts: 107
If you declare a class "abstract" then it cannot be instantiated. That is you can't make an instance of it.
The diffrence between an abstract class and a interface is that an abstract class can have none abstract methods.
If you should make a abstract class of a man,woman,boy,etc then you should try to locate something that they all have incommon.
Ears, Eyes, head, neck, body, and so on.
In an abstract class you can return values in a method

if you had a abstract method in the abstract class then you would force the Girl class to include the method.


Here you would have a compile error because the Girl class didn't include the getName method. It's up to the Girl class to supply the implementation of the getName() method.
Hope this make sence. There are probably experienced java programmers that would explain this more clearly.
// Mathias


SCJP2 , MCP( 70-229 ) , Preparing For SCWDC
Nancy Bradley
Ranch Hand

Joined: Feb 25, 2004
Posts: 32
Thanks, I will try again
Nancy
 
 
subject: Please Help I am lost!!!