Too many methods problem
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:
1. Main_Program - Call method in Ledger called getAccountEntryAmount(AccountEntryID)
2. Ledger - Call method in Account called getAccountEntryAmount(AccountEntryID)
3. Account - Call method in AccountEntry called getAccountEntryAmount(AccountEntryID)
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?
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL