GIDForums

Go Back   GIDForums > Computer Programming Forums > CPP / C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 15-Mar-2008, 16:31
TS3BxL TS3BxL is offline
New Member
 
Join Date: Mar 2008
Posts: 4
TS3BxL is on a distinguished road
Question

Linked Lists Database...


Hello Everyone.

Project outline:
Quote:
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.
  #2  
Old 15-Mar-2008, 19:04
C++_Bandit's Avatar
C++_Bandit C++_Bandit is offline
Junior Member
 
Join Date: Mar 2008
Location: Virginia
Posts: 40
C++_Bandit will become famous soon enough

Re: Linked Lists Database...


Just a quick question before I can help you: how long have you been programming using C++?
  #3  
Old 15-Mar-2008, 20:18
TS3BxL TS3BxL is offline
New Member
 
Join Date: Mar 2008
Posts: 4
TS3BxL is on a distinguished road

Re: Linked Lists Database...


1 Year now...
  #4  
Old 16-Mar-2008, 13:42
C++_Bandit's Avatar
C++_Bandit C++_Bandit is offline
Junior Member
 
Join Date: Mar 2008
Location: Virginia
Posts: 40
C++_Bandit will become famous soon enough

Re: Linked Lists Database...


Great! then you should know about member functions. what I would suggest is instead of having a class that just does the add/subtract transactions is have those in the transaction class. also, can you use your own header files? does/can this be modular or does it have to remain in the same file?
  #5  
Old 17-Mar-2008, 22:16
TS3BxL TS3BxL is offline
New Member
 
Join Date: Mar 2008
Posts: 4
TS3BxL is on a distinguished road

Re: Linked Lists Database...


So If i wanted to do a Stock of car models for the Distributor I should make a Car Node ?

CPP / C++ / C Code:
struct CarNode
{
    char model;
    void displayModel() {cout << model;}
    CarNode * next;
};

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 ?
Last edited by admin : 18-Mar-2008 at 04:32. Reason: Please insert your example C/C++ codes between [CPP] and [/CPP] tags
  #6  
Old 18-Mar-2008, 11:02
C++_Bandit's Avatar
C++_Bandit C++_Bandit is offline
Junior Member
 
Join Date: Mar 2008
Location: Virginia
Posts: 40
C++_Bandit will become famous soon enough

Re: Linked Lists Database...


That's a start, but you really should declare the model as a string. When you declare it as a char that, generally, only allows you to store a single character into the variable. With a string, you can include the entire name. Also, as a part of it you should include a variable that stores the number of cars available. Or if you wanted you could declare another struct that includes the number of cars available (but I think this would be a bit too complicated) Also, I believe you stated that you need to store the price of that model, so I would suggest another variable that stores that price.

So, here's what I suggest:
CPP / C++ / C Code:
struct carNode
{
    string model;
    int numberOfCars;
    double priceOfCar;

    void displayModel() {cout << model};

    carNode * nextModel;
};

So, now that you have your carNode, you can create other classes or structs that'll change the amount of cars you have. I hope this helps.
  #7  
Old 18-Mar-2008, 23:51
Peter_APIIT Peter_APIIT is offline
Regular Member
 
Join Date: May 2007
Location: Malaysia
Posts: 348
Peter_APIIT is on a distinguished road

Re: Linked Lists Database...


Why u use struct instead of class since class is private by default and struct is public buy default ?

This is not a good OOP design principles.
__________________
Linux is the best OS in the world.
  #8  
Old 19-Mar-2008, 05:27
C++_Bandit's Avatar
C++_Bandit C++_Bandit is offline
Junior Member
 
Join Date: Mar 2008
Location: Virginia
Posts: 40
C++_Bandit will become famous soon enough

Re: Linked Lists Database...


Quote:
Originally Posted by Peter_APIIT
Why u use struct instead of class since class is private by default and struct is public buy default ?

This is not a good OOP design principles.

True, but it really doesn't matter since you can make any part of a struct or class private or public. It depends on what the programmer is comfortable using. I just suggested a struct because that was what the original design.

By the way, TS3BxL, you never answered me: can you create your own header files and modules or does this have to be in a single file?
  #9  
Old 19-Mar-2008, 12:42
TS3BxL TS3BxL is offline
New Member
 
Join Date: Mar 2008
Posts: 4
TS3BxL is on a distinguished road

Re: Linked Lists Database...


Quote:
Originally Posted by C++_Bandit
can you create your own header files and modules or does this have to be in a single file?

my bad, Yes you can create your own header files and modules...
  #10  
Old 19-Mar-2008, 19:01
C++_Bandit's Avatar
C++_Bandit C++_Bandit is offline
Junior Member
 
Join Date: Mar 2008
Location: Virginia
Posts: 40
C++_Bandit will become famous soon enough

Re: Linked Lists Database...


do you need anymore help at the moment?
 

Recent GIDBlogNew Corolla Altis, 10th Generation - Part I by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linked Lists advice request promsan C Programming Language 74 23-May-2007 08:29
Linked Lists problem kracivi C Programming Language 1 01-May-2007 08:40
Doubly linked lists in C++ sweeeeeeetlipss CPP / C++ Forum 1 23-Oct-2006 23:27
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 13:12
Linked lists vortz83 CPP / C++ Forum 3 20-Mar-2004 06:56

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 13:09.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.