Alright, well it seems that you've got a good start and everything is your own work, so I'll be happy to give you some guidance.
The most important part of your code is your implementation of your class files. This is done in the main method which you have already declared:
CODE
public static void main (String [] args){
Scanner scanner = new Scanner (System.in);
}
When you compile your code and run it, this is what is going to be run, so this is where you have to put all of your instructions.
Creating objects and running methods are pretty much what you need to be worried about in your main method. Create an object from a class file, what you need to do is use the "new" operator.
For your given class- Client, this would be done as follows:
CODE
Client myClient = new Client("Bob", 33123, 555);
Alright, so let's break this down, on the left side of the equals sign, you have:
Client myClient
This is the same way that you would go about declaring any variable:
int int1;
String str;
etc.
You give the type of object you are creating, then its variable name. So, anytime you want to use your newly created Client object, you call the variable name myClient, similarly to as if you wanted to call the int int1, or the String str.
Now for the right side:
new Client("Bob", 33123, 555)
Without getting into too much detail, when you create an object, you need to declare it as new, because in essence, you are creating something from scratch.
Now, notice this part:
Client("Bob", 33123, 555)
this code fits the form for the constructor that you created for your Client object:
public Client (String name, int id, int pin)
The client has a String - "Bob"
an int - 33123
and another int - 555
When you create an object, you based on the constructor that you created for the class. In this way it acts like a kind of blueprint for what you wish to build.
So, put all of this together:
CODE
Client myClient = new Client("Bob", 33123, 555);
You have a Client object designated by the name myClient
it has a String variable- name: containing the info "Bob"
it has an int variable- id: containing the number 33123
and it has another int variable- pin: containing the number 555
In addition to all of this, your object also has a number of methods at its disposal (some of which you are about to write):
QUOTE
String get_name() which gets the name of the client
int get_id() which gets the ID of the client
void set_id(int id) which sets the ID of the client
int get_pin() which gets the PIN of the client
void set_pin(int pin) which sets the PIN of the client
SavingsAccount get _savings() which gets savings account of the client & returns null if he hasnt one
void set_savings(SavingsAccount sa) which sets the savings account of the client
RspAccount get_rsp() which gets Rsp account of a client & returns null if he hasnt one
void set_rsp(RspAccount ra) which sets Rsp account of the client
boolean has_savings() which returns true if client has savings account, false if he hasnt
boolean has_rsp() which returns true if client has rsp account, false if he hasnt
double total_asset() returns the client's total assets in existing accounts
Now, as for calling all of these methods, you are going to need to use the dot (.) operator.
Remember, the name of your client object is myClient, and you are trying to access methods that myClient has. Using the dot operator to do this would look something like this:
CODE
myClient.get_name();
Calling this will run your get_name() method under you Client class. Use a similar format for any other method you may have.
Alright, I know I jumped around a bit, but I hope that this at least helped a little bit. I'd be happy to help you with anything else you need, or to clarify any of the points I may not have explained too well.
Good luck.
This post has been edited by keems21: 23 Mar, 2007 - 09:43 AM