Hi all,
I wonder if you can help me with this.
I am looking at a fairly long (well at least for me) java program, about 700 lines. Basically it's a very very basic simulation of an ATM that can run on a computer.
Now, in all the classes I have declared so far, I have invariably used variables of primitive type and sometimes reference-type, the latter usually declared in the
java file that contains the main method in. This time I have come across this situation:
Take a few classes:
public class ATM{
...
}
public class Screen{
...
}
public class Keypad{
...
}
etc..
In class ATM we declare a few variables of primitive type and also a few reference-type variables, like so:
public class ATM{
private int account;
private double amount;
private Screen screen;
private Keypad keypad;
}
These reference-type declaration confuse me a bit. I know the reason why these have been declared (ATM
needs to exchange information with Screen
, Keypad
etc) but I don't understand the mechanism. Does anybody have a short working example (not 700 lines :-)) that I can look at so I understand this correctly before delving into the ATM program?
thanks