Data Structure


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Data Structure

  1. #1
    Join Date
    Mar 2005
    Posts
    27

    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!

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    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.

  3. #3
    Join Date
    Mar 2005
    Posts
    27

    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.

  4. #4
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    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.

  5. #5
    Join Date
    Mar 2005
    Posts
    27

    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.

  6. #6
    Join Date
    Mar 2005
    Posts
    27

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center