Hey,
I have a question in relation to linked lists.
I have a problem that I am working on. It requires me to create two linked lists. One for dvd rental customers and the second for their accounts. I have 8 files at the moment. customer.h, customer.cpp, customerlist.h, customerlist.cpp, account.h, account.cpp, accountlist.h, accountlist.cpp
I have to create a store.h and store.ccp file as well as a storelist.h and storelist.cpp
We have been supplied with the storelist.h file here
It shows an ability to search a customer by their ID, last name and search an account by their customer ID
1 2 3 4
Class storelist {
customerLL* headByID; //LL ordered by id
customerLL* heaadByLastName; //LL ordered by last name
accountLL* headByID;
I have no idea what way I have to do the other files.
Any ideas?
Why do you need to make a completely new class each time you need to store a list of an existing class? Have you learned about templates yet? Do you HAVE to write the list classes yourself?
Yeah I wasn't sure about that myself. We haven't done templates yet. The description of the project is as follows.
Implement a Video Store database using linked lists. A Store comprises a list of customers and a list of accounts. Two files, customers0.txt and accounts0.txt contain customer records and account records for the store, respectively. Each customer record comprises a customerID, a lastName, a firstName and an address (just a town). Each account record comprises an accountID, a customerID and a balance (in cents). A customer may have more than one account, but an account may not belong to more than one customer (ie. no joint accounts). customerIDs start at 80000000 and accountIDs start at 90000000. customerIDs and accountIDs are unique. Implement Customer, Account, CustomerList, StoreList, Store and any other appropriate classes you might need required to implement the store database.
In your main function, create a store object and populate it with data from the two input files.
Well, I was talking about the fact that you have the classes V, W, X, and Y, and then you have Vlist, Wlist, Xlist, and Ylist, and now you want to add Z and Zlist. Don't you think it's a bit redundtant?
As for the assignment, you may want to structure your program such that a store has a list of customers, and each customer has a list of accounts. This makes sense because the problem said that there can be more than one account per customer but not vice versa.
I suppose to be safe, you should write the program by making and remaking each linked list class yourself (the hard way). I've never understood why some things you are not allowed to know until later...
For the linked list implementation, you'll need a subclass for each node, that points to the previous and next elements (or just the next element for forward-only traversing). The main lass will need pointers to the first and last nodes.