If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Too many methods problem

Hi,

I am trying to make a small general ledger program which will consist of the following classes:
- Main_Program - displays a text based menu for recording different transactions
- Ledger - class that holds a List/HashMap of Account objects
- Account - class that holds the String AccountName and int AccounNo along with a List/HashMap that holds AccountEntry objects
- AccountEntry - Object that stores the date particulars and amount of the transaction along with an int AccountEntryID.

The problem is that if I want to display an amount from an AccountEntry I have to use the following method calls:

All these methods to get one AccountEntryAmount value. If I were to have many Ledger type lists such as customer lists etc the Main_Program will have methods corresponding to all the lowest level class' methods.

Is there a shortcut to access a variable (eg AccountEntryAmount) that is so deeply nested i.e main_Program-->Ledger-->Account-->AccountEntry-->Amount, so as to avoid so many identical methods calls?

So the Main program gets a ledger, and that ledger contains the accounts
with the entries that they all want to read, right ?
Then Main and ledger and all other interested parties need (at least) a method like: