Home arrow static arrow Java Programming [Archive] - Java help needed!
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Java help needed!
This topic has 2 replies on 1 page.

Registered: 7/14/04
Java help needed!  
Jul 14, 2004 10:25 PM


I am not sure if this is the right forum to post this in but I am going to try anyway. I have a Java test tomorrow only I am so stuck. I have a practise test to work through but I am not even sure what the questions are asking or how to go about creating the class.

I need to code a class to define the characteristics and behaviour of athletes in an Athletics Club The class is to be called Athlete.java and is to have the following:

(a) 4 instance fields for the class as shown below:

Identifier data type
name String
Grade Int
Phone String

(b) 3 accessor (or get) methods to return the values of the 4 instance fields - 1 method for each instance field and to be called:

(c) A static variable called totalMembers of data type int to store a running total of the number of athletes in the club.

(d) A constructor with 3 parameters to accept the values of name, grade, phone, and store them in the instance fields. The constructor should also add 1 to totalMembers each time it is used.

(e) A method called calculateFee that has no parameters and returns a fee based on the following table.

Grade Fee
1 $ 100.00
2 $ 150.00
3 $ 220.00

The return value is a double

(f) A method called getTotalMembers() which returns the totalMembers..

Can someone please help? I am so confused!

Registered: 13.8.2003
Re: Java help needed!  
Jul 14, 2004 10:39 PM (reply 1 of 2)

You're screwed and it's all your own fault...

Registered: 21.03.00
Re: Java help needed!  
Jul 14, 2004 11:27 PM (reply 2 of 2)


Hmm.. it would be better if you opened the book and looked at the chapters about declaring classes and methods.

I will however help you a bit.

public class Example {    //An instance field named name    private String name;     //A constructor that takes one argument    public Example(String name) {        this.name = name;        }     //An accessor method named getName    public String getName() {        return name;    }}

Now try to understand the example... look in the book and try to solve your problem.

This topic has 2 replies on 1 page.