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.

Recommended Answers

All 4 Replies

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:

CarDistributor:
   has a name
   has a list of dealers
   has a total number of cars
   has a list of cars
   has a total inventory value
   has a list of each car model and the number of cars of that model
   can add, delete, display car dealers
   can add, delete, display cars
   can add, delete, display car models
   can display total number of cars
   can display a given model and number of cars of that model
   can display all models and number of cars of each model. 
   can display models and number of cars of each model by dealer
   can display inventory value
   can change inventory value 
   can search for a given car model by dealer
  
CarDealer
    has everything a CarDistributor has except a list of CarDealers
    has an id
   can do everything a CarDistrubtor can except add, delete, etc CarDealers
   can display id

Car
  has a model
  has a price
  can display model
  can display price

Each has represents a member variable
Each can represents a member function 

To make the various lists I'd probably have the following classes:

CarNode to make a list of cars
DealerNode to make a list of dealers
Model Node to make a list of models

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...

Version 1:
struct CarDealer
{
    string name;
    void displayName(){cout << name;}    
};

struct CarDealerNode
{
    CarDealer dealer;
    CarNode * next;
};

Version 2
struct CarDealerNode
{
    string name;
    void displayName() {cout << name;}
    CarDealerNode * next;
};

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.

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

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 ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.