Linked Lists Database...

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 20
Reputation: R3B3L is an unknown quantity at this point 
Solved Threads: 0
R3B3L R3B3L is offline Offline
Newbie Poster

Linked Lists Database...

 
0
  #1
Mar 15th, 2008
Hello Everyone.

Project outline:
I've to make a project which is the following:
I'm a Car Distributor that distributes(sells) cars to different Car Dealers I should have a stock class with all the different types of cars I have ej(Toyota: 100, Mistubishi: 220, etc...) each type of car should have its own price, each dealer should have a name and an id, i should make a database storing all that information, I should use linked lists with the restriction of the following libraries iostream, cmath, fstream, cstring.
So far this is what I've come up with:
I made the following classes;

Car Class -- stores car model, car price
Dealer Class -- stores dealer name, dealer id
Transaction Class -- inherits from Car and Dealer
Distributor Class -- has the operation to add, remove transactions etc..
Node Class -- linked lists

I don't think I'm doing this right, Any suggestions on how to design this, on how many classes I should use would be appreciated.

Thank You.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,678
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 264
Lerner Lerner is offline Offline
Posting Virtuoso

Re: Linked Lists Database...

 
0
  #2
Mar 15th, 2008
I suspect you've posted your interpretation of what you're supposed to do. I suspect there are a few more details that exist in the original instruction set. Here's how I would start thinking of class design based on the information posted and trying to read between the lines:
  1. CarDistributor:
  2. has a name
  3. has a list of dealers
  4. has a total number of cars
  5. has a list of cars
  6. has a total inventory value
  7. has a list of each car model and the number of cars of that model
  8. can add, delete, display car dealers
  9. can add, delete, display cars
  10. can add, delete, display car models
  11. can display total number of cars
  12. can display a given model and number of cars of that model
  13. can display all models and number of cars of each model.
  14. can display models and number of cars of each model by dealer
  15. can display inventory value
  16. can change inventory value
  17. can search for a given car model by dealer
  18.  
  19. CarDealer
  20. has everything a CarDistributor has except a list of CarDealers
  21. has an id
  22. can do everything a CarDistrubtor can except add, delete, etc CarDealers
  23. can display id
  24.  
  25. Car
  26. has a model
  27. has a price
  28. can display model
  29. can display price
  30.  
  31. Each has represents a member variable
  32. Each can represents a member function
  33.  
  34. To make the various lists I'd probably have the following classes:
  35.  
  36. CarNode to make a list of cars
  37. DealerNode to make a list of dealers
  38. Model Node to make a list of models
  39.  
Last edited by Lerner; Mar 15th, 2008 at 10:45 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 20
Reputation: R3B3L is an unknown quantity at this point 
Solved Threads: 0
R3B3L R3B3L is offline Offline
Newbie Poster

Re: Linked Lists Database...

 
0
  #3
Mar 16th, 2008
I hope I'm not asking too much but can you give a simple code example of each class only containing 1 data member 1 method, I'm new to linked lists so I don't know how to incorporate them with the rest of the class...
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,678
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 264
Lerner Lerner is offline Offline
Posting Virtuoso

Re: Linked Lists Database...

 
0
  #4
Mar 17th, 2008
  1. Version 1:
  2. struct CarDealer
  3. {
  4. string name;
  5. void displayName(){cout << name;}
  6. };
  7.  
  8. struct CarDealerNode
  9. {
  10. CarDealer dealer;
  11. CarNode * next;
  12. };
  13.  
  14. Version 2
  15. struct CarDealerNode
  16. {
  17. string name;
  18. void displayName() {cout << name;}
  19. CarDealerNode * next;
  20. };

You really need a good tutorial or book to assist you if you are going to try to do this with minimal knowledge of both classes and lists. There's a lot of details, options, etc to learn about and choose from.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 20
Reputation: R3B3L is an unknown quantity at this point 
Solved Threads: 0
R3B3L R3B3L is offline Offline
Newbie Poster

Re: Linked Lists Database...

 
0
  #5
Mar 18th, 2008
So If i wanted to do a Stock of car models for the Distributor I should make a Car Node ?

  1. struct CarNode
  2. {
  3. char model;
  4. void displayModel() {cout << model;}
  5. CarNode * next;
  6. };

I need to make a stock which has a number of car types (Toyota, Mistubishi, etc..)
I should assign an initial value of how many cars I have ( Toyota 200, Mistubishi 100...)
Then when I sell for example 50 Toyotas and 20 Mistubishis It should be subtracted from
my stock, I also should be able to add new cars or add more Toyotas to my stock which will raise the number of the Toyotas I should also be able to add new models and set their prices...

Cal I achieve that by making a CarNode ? I'm really haveing a hard time thinking this though if theres no much trouble could you give me a code example ?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC