-
Data Structure
Hello everyone! I am having problems designing a data structure that keeps track of the dollar amount of purchases made by those clients that have regular accounts which are numbered 0, 1, .... n. In the problem one does not know in advance how many purchases each account will have. There are some that have one or two purchases while others have 50. Does anyone have any idea on how to design this data structure? If anyone can assist me I would appreciate it much. Thanks!
-
You must make yourself a Client class and an Account class. The Client class can then
store all the Client's Accounts in an internal ArrayList.
-
Thanks!
Do you have any suggestions of the methods that could be in each class. Where should the array be declared?
Last edited by none_none; 04-21-2005 at 12:27 PM.
-
As a see it you should have an addtional litle class: Purchase
class Purchase {
int transactNo;
double amount;
Date purchaseDate;
String description;
}
Client:
fields:
(clientNumber, name, addr ... blabla)
ArrayList accountList; // list of all accounts for Client
methods:
public void addAccount(Account acc);
public Account getAccount(int accNumber);
public void closeAccount(int accNumber);
Account:
fields:
(Client number, opened date.. blabla)
ArrayList purchaseList; // list of all purchases for account
methods:
public int addPuchase(Purchase aPurchase); // returns a system wide unique transaction number
public void listPurchases(Date fromDate, Date toDate);
public Purchase getPurchase(int transactNo);
Last edited by sjalle; 04-21-2005 at 01:12 PM.
-
Thanks
Thank you man. I really appreciate your help. You have been of much help. I will work with what is provided and go from there. Thanks once more for the help.
-
Unable to figure it out
I am still unable to figure out how to complete this data struture. Is there anyway that you can show me how you would go about completing a design like this one. I would be of great help if you could help me out. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks