Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

would you please help me with the below assignment using C++ : Project #5 Store

ID: 3740166 • Letter: W

Question

would you please help me with the below assignment using C++ :

Project #5 Store

CISP 400 C++ Programming

Inheritance                                                               

Using the last assignment, create a class Store that will track inventory.

This class will contain a private fixed-size array of pointers to Inventory items from the last project.

It will have only three public member functions:

1.    A default constructor that will create an empty Store.

2.    A destructor. The destructor will clean up

3.    A member function void Run(); This will start the inventory control program and display a menu through which the user may interact with the object. The menu should offer the following choices

1.    Enter a new item into inventory

2.    Display the inventory.

3.    Display the total quantity of inventory items.

4.    Display the totals: total gross profits.

5.    Quit.

4.    NO MORE! Only three!

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

The last assignment was:

Project #4 Inventory

CISP 400 Programming Project #4

Inheritance

For this assignment, we will start with a base class that I have provided: Inventory[1].

This is an abstract base class. You will publicly inherit:

·         Inventory

o    Hardware

§ Fastener

§ Hinge

o    Lumber

§ Hardwood

§ Softwood

o    Pipe – I will provide these as examples

§ Plastic

For every data member of every class provide set and get functions

Class Hardware will have a private data member of _material_type, an enumerated type Material_Type {MTunknown, Stainless, Steel, Copper, Bronze}.

Class Lumber will have a private data member of _surfacing_type, an enumerated type Surfacing_Type {STunknown, Rough, S2S, S4S}.

Class Fastener will have a private data member _fastener_type, an enumerated type Fastener_Type {FTunknown, Nails, Screw, Bolt}; a private data member _profit_margin that will be a percentage stored as a float: Nails 5%, Screws 7.5%, Bolts 10%; a private data member _pieces which will store the number in Inventory.

Class Hinge will have a private data member _hinge_type, an enumerated type Hinge_Type {HTunknown, Butt, Overlay, Offset} a private data member _pieceswhich will store the number in Inventory. All hinges will have a profit margin of 12.5%.

Class Hardwood will have a private data member _wood_type, an enumerated type Wood_Type { WTunknown, Oak, Maple, Birch}; a private data member _board_feet which will store the number of board feet in this lot of Inventory. Profit margins are: Oak 15%, Maple 18%, Birch 12.5%.

Class Softwood will have a private data member _thickness, an unsigned; _units an unsigned that tracks the number of units in stock; profit margin: 5% plus .1% for every ¼” of thickness. For example the profit margin for ¾ thick lumber is 5% + 3 * .1% = 5.3%. Lumber that is 1.5” thick would be 5% + 6 * .1% = 5.6%. All Softwood has a SurfacingType of S4S.

All of these enumerated types will be declared in the public part of the class. See Pipe and Plastic for examples of this. Common attributes should be collected into common base classes – we will talk about this in class.

[1] Real UPC codes are exactly 12 numeric characters. 12! Do we feel like typing 12 characters every time we want to test our code? No! So, I have shortened the length to 3. I have used a const: change it to 12 and it is real-world correct. But, the const is in my implementation file, so you do not have access to it.

Explanation / Answer

//main.cpp
#include "Store.h"

int main()
{
    Store s;
    s.Run();

    return 0;
}
------------------------------------------------------
//Store.cpp
#include "Store.h"
#include "Fastener.h"
#include "Hinge.h"
#include "Hardwood.h"
#include "Softwood.h"
#include "Plastic.h"

Store::Store()
{
    _num = 0;

    for (int i = 0; i < MAX; i++)
        _store[i] = NULL;
}

Store::~Store()
{
    for (unsigned i = 0; i < _num; i++)
        delete _store[i];
}

void Store::Run()
{
    cout << " Choose One of the Following: "
         << "1. Enter a new item into inventory "
         << "2. Remove an item from inventory "
         << "3. Display the inventory "
         << "4. Display the totals: gross profits per item type and total gross profits "
         << "5. Quit ";

    int option = 0;
    cin >> option;

    switch (option) {
        case 1:
            newItem();
            break;
        case 2:
            removeItem();
            break;
        case 3:
            displayInventory();
            break;
        case 4:
            displayTotals();
            break;
        case 5:
            return;
            break;

        default:
            cout << " Error -- Invalid Choice. ";
            Run();
            break;
    }
}

void Store::newItem()
{
    if (_num == MAX) {
        cout << "There are too many items in the inventory. Remove an item before trying to add another." << endl;
        Run();
        return;
    }

    cout << " Choose which item to add to inventory: "
         << "1. Fastener "
         << "2. Hinge "
         << "3. Hardwood "
         << "4. Softwood "
         << "5. Plastic ";

    int option = 0;
    cin >> option;

    switch (option) {
        case 1:
            _store[_num++] = new Fastener(Fastener::Nails, 56);
            cout << " You have added a new Fastener to the inventory." << endl;
            break;
        case 2:
            _store[_num++] = new Hinge(Hinge::Butt, 99);
            cout << " You have added a new Hinge to the inventory." << endl;
            break;
        case 3:
            _store[_num++] = new Hardwood(Hardwood::Maple, 34);
            cout << " You have added a new Hardwood to the inventory." << endl;
            break;
        case 4:
            _store[_num++] = new Softwood(Softwood::Redwood, 12);
            cout << " You have added a new Softwood to the inventory." << endl;
            break;
        case 5:
            _store[_num++] = new Plastic();
            cout << " You have added a new Plastic to the inventory." << endl;
            break;
        default:
            cout << " Error -- Invalid Choice. ";
            newItem();
            return;
            break;
    }

    Run();
}

void Store::removeItem()
{
    if (_num == 0) {
        cout << "There are no items in the inventory. Add an item before trying to remove one." << endl;
        Run();
        return;
    }

    delete _store[--_num];
    cout << "You have removed an item from the inventory." << endl;

    Run();
}

void Store::displayInventory()
{
    if (_num == 0) cout << "There are no items in inventory to display." << endl;

    for (unsigned i = 0; i < _num; i++)
    {
        _store[i]->display(cout);
        cout << endl;
    }

    Run();
}

void Store::displayTotals()
{
    if (_num == 0) cout << "There are no items in inventory." << endl;

    float totalProfit = 0;

    for (unsigned i = 0; i < _num; i++)
    {
        totalProfit += _store[i]->gross_profit();
        _store[i]->display(cout);
        cout << "Gross profit for item: $" << _store[i]->gross_profit() << endl << endl;
    }

    cout << " Total gross profit is: $" << totalProfit << endl;

    Run();
}
--------------------------------------------------------------------------------------
//Store.h
#include <iostream>
#include "Inventory.h"

using namespace std;

#ifndef STORE_H
#define STORE_H

#define MAX 20

class Store
{
    Inventory *_store[MAX];
    unsigned _num;

    void newItem();
    void removeItem();
    void displayInventory();
    void displayTotals();

public:
    Store();
    ~Store();

    void Run();
};

#endif
----------------------------------------------------------
//Softwood.cpp
#include "Softwood.h"

Softwood::Softwood()
        :Lumber()
{
    _wood_type = Softwood::WTunknown;
    Lumber::setSurfacingType(Lumber::S4S);
    _thickness = 1;
    _units = 4;
}

Softwood::Softwood(Softwood::Wood_Type type, float cost)
        :Lumber()
{
    setWoodType(type);
    set_cost(cost);
    Lumber::setSurfacingType(Lumber::S4S);
    _thickness = 1;
    _units = 4;
}

Softwood::Softwood(string upc, Date purchased, float cost)
        :Lumber(upc, purchased, cost, Lumber::S4S, 1)
{
    _wood_type = Softwood::WTunknown;
    _thickness = 1;
    _units = 4;
}

Softwood::Softwood(string upc, Date purchased, float cost, string* suppliers, unsigned num_suppliers)
        :Lumber(upc, purchased, cost, suppliers, num_suppliers)
{
    _wood_type = Softwood::WTunknown;
    Lumber::setSurfacingType(Lumber::S4S);
    _thickness = 1;
    _units = 4;
}

Softwood::Softwood(string upc, Date purchased, float cost, Wood_Type t, float wt)
        :Lumber(upc, purchased, cost, Lumber::S4S, 1)
{
    _wood_type = t;
    _thickness = 1;
    _units = 4;
}

Softwood::~Softwood()
{

}

void Softwood::setUnits(unsigned units)
{
    _units = units;
}

void Softwood::setThickness(unsigned thickness)
{
    _thickness = thickness;
}

void Softwood::setWoodType(Softwood::Wood_Type type)
{
    _wood_type = type;
}

unsigned Softwood::getThickness() const
{
    return _thickness;
}

Softwood::Wood_Type Softwood::getWoodType() const
{
    return _wood_type;
}

void Softwood::display(ostream &os) const
{
    Lumber::display(os);
    string ht[4] = { "Unknown", "Pine", "Redwood", "Fir" };
    os << "Softwood type: " << ht[_wood_type] << endl
       << "Thickness: " << getThickness() << endl
       << "Units: " << quantity() << endl;
}

float Softwood::gross_profit() const
{
    return (0.05 + _thickness * 0.01) * get_cost() * quantity();
}

unsigned Softwood::quantity() const
{
    return _units;
}
----------------------------------------------------------------
//Softwood.h
#ifndef SOFTWOOD_H
#define SOFTWOOD_H

#include "Lumber.h"

class Softwood : public Lumber
{
public:
    enum Wood_Type { WTunknown, Pine, Redwood, Fir};

    Softwood();
    Softwood(Softwood::Wood_Type, float);
    Softwood(string, Date, float);
    Softwood(string, Date, float, string*, unsigned);
    Softwood(string, Date, float, Softwood::Wood_Type, float);
    ~Softwood();

    void setUnits(unsigned);
    void setThickness(unsigned);
    void setWoodType(Softwood::Wood_Type);

    unsigned getThickness() const;
    Softwood::Wood_Type getWoodType() const;

    virtual void display(ostream &) const;
    virtual float gross_profit() const;
    virtual unsigned quantity() const;

private:
    Softwood::Wood_Type _wood_type;
    unsigned _thickness;
    unsigned _units;
};

#endif


-------------------------------------------------------------------
//Fastner.cpp
#include "Fastener.h"

Fastener::Fastener()
        :Hardware()
{
    setFastenerType(FTunknown);
    Hardware::setMaterialType(Hardware::Steel);
    _pieces = 1;
}

Fastener::Fastener(Fastener::Fastener_Type type, float cost)
        :Hardware()
{
    setFastenerType(type);
    set_cost(cost);
    Hardware::setMaterialType(Hardware::Steel);
    _pieces = 1;
}

Fastener::Fastener(string upc, Date purchased, float cost)
        :Hardware(upc, purchased, cost, Hardware::Steel, 1)
{
    setFastenerType(FTunknown);
    _pieces = 1;
}

Fastener::Fastener(string upc, Date purchased, float cost, string* suppliers, unsigned num_suppliers)
        :Hardware(upc, purchased, cost, suppliers, num_suppliers)
{
    setFastenerType(FTunknown);
    Hardware::setMaterialType(Hardware::Steel);
    _pieces = 1;
}

Fastener::Fastener(string upc, Date purchased, float cost, Fastener_Type ft, float wt)
        :Hardware(upc, purchased, cost, Hardware::Steel, 1)
{
    setFastenerType(ft);
    _pieces = 1;
}

Fastener::~Fastener()
{

}

void Fastener::setQuantity(unsigned quantity)
{
    _pieces = quantity;
}

void Fastener::setFastenerType(Fastener::Fastener_Type type)
{
    _fastener_type = type;
    setProfitMargin();
}

void Fastener::setProfitMargin()
{
    switch (_fastener_type) {
        case Nails:
            _profit_margin = 0.05;
            break;

        case Screw:
            _profit_margin = 0.075;
            break;

        case Bolt:
            _profit_margin = 0.1;
            break;

        default:
            _profit_margin = 0;
            break;
    }
}

Fastener::Fastener_Type Fastener::getFastenerType() const
{
    return _fastener_type;
}

float Fastener::getProfitMargin() const
{
    return _profit_margin;
}

void Fastener::display(ostream &os) const
{
    Hardware::display(os);
    string ft[4] = { "Unknown", "Nails", "Screw", "Bolt" };
    os << "Fastener type: " << ft[_fastener_type] << endl
       << "Pieces: " << quantity() << endl
       << "Profit Margin: " << getProfitMargin() << endl;
}

float Fastener::gross_profit() const
{
    return _profit_margin * get_cost() * quantity();
}

unsigned Fastener::quantity() const
{
    return _pieces;
}
----------------------------------------------
//Fastener.h
#ifndef FASTENER_H
#define FASTENER_H

#include "Hardware.h"

class Fastener : public Hardware
{
public:
    enum Fastener_Type { FTunknown, Nails, Screw, Bolt};

    Fastener();
    Fastener(Fastener::Fastener_Type, float);
    Fastener(string, Date, float);
    Fastener(string, Date, float, string*, unsigned);
    Fastener(string, Date, float, Fastener::Fastener_Type, float);
    ~Fastener();

    void setQuantity(unsigned);
    void setFastenerType(Fastener::Fastener_Type);
    void setProfitMargin();

    Fastener::Fastener_Type getFastenerType() const;
    float getProfitMargin() const;

    virtual void display(ostream &) const;
    virtual float gross_profit() const;
    virtual unsigned quantity() const;

private:
    Fastener::Fastener_Type _fastener_type;
    float _profit_margin;
    unsigned _pieces;
};

#endif
----------------------------------------------------------------
//Hardware.cpp
#include "Hardware.h"

Hardware::Hardware()
        :Inventory()
{
    _material_type = Hardware::MTunknown;
}

Hardware::Hardware(string upc, Date purchased, float cost, string *suppliers, unsigned numSuppliers)
        :Inventory(upc, purchased, cost, suppliers, numSuppliers)
{
    _material_type = Hardware::MTunknown;
}

Hardware::Hardware(string upc, Date purchased, float cost, Hardware::Material_Type type, unsigned inStock)
        :Inventory(upc, purchased, cost)
{
    _material_type = type;
    _inStock = inStock;
}

Hardware::~Hardware()
{

}

void Hardware::setMaterialType(Hardware::Material_Type type)
{
    _material_type = type;
}

void Hardware::setInStock(unsigned inStock)
{
    _inStock = inStock;
}

Hardware::Material_Type Hardware::getMaterialType() const
{
    return _material_type;
}

unsigned Hardware::getInStock() const
{
    return _inStock;
}

void Hardware::display(ostream &os) const
{
    Inventory::display(os);

    string type[5] = { "Unknown", "Stainless", "Steel", "Copper", "Bronze" };
    os << "Material: " << type[_material_type] << endl;
}
---------------------------------------------------------------------------------------
//Hardware.h
#ifndef HARDWARE_H
#define HARDWARE_H

#include "Inventory.h"

class Hardware : public Inventory
{
public:
    enum Material_Type { MTunknown, Stainless, Steel, Copper, Bronze };

    Hardware();
    Hardware(string, Date, float, string * = NULL, unsigned = 0);
    Hardware(string, Date, float, Hardware::Material_Type, unsigned);
    ~Hardware();

    void setMaterialType(Hardware::Material_Type);
    void setInStock(unsigned);

    Hardware::Material_Type getMaterialType() const;
    unsigned getInStock() const;

    virtual void display(ostream &) const;

private:
    Hardware::Material_Type _material_type;
    unsigned _inStock;
};

#endif
-----------------------------------------------------------------------
//Hardwood.cpp
#include "Hardwood.h"

Hardwood::Hardwood()
        :Lumber()
{
    _wood_type = Hardwood::WTunknown;
    Lumber::setSurfacingType(Lumber::Rough);
    _board_feet = 3;
}

Hardwood::Hardwood(Hardwood::Wood_Type type, float cost)
        :Lumber()
{
    setWoodType(type);
    set_cost(cost);
    Lumber::setSurfacingType(Lumber::Rough);
    _board_feet = 3;
}

Hardwood::Hardwood(string upc, Date purchased, float cost)
        :Lumber(upc, purchased, cost, Lumber::Rough, 1)
{
    _wood_type = Hardwood::WTunknown;
    _board_feet = 3;
}

Hardwood::Hardwood(string upc, Date purchased, float cost, string* suppliers, unsigned num_suppliers)
        :Lumber(upc, purchased, cost, suppliers, num_suppliers)
{
    _wood_type = Hardwood::WTunknown;
    Lumber::setSurfacingType(Lumber::Rough);
    _board_feet = 3;
}

Hardwood::Hardwood(string upc, Date purchased, float cost, Wood_Type t, float wt)
        :Lumber(upc, purchased, cost, Lumber::Rough, 1)
{
    _wood_type = t;
    _board_feet = 3;
}

Hardwood::~Hardwood()
{

}

void Hardwood::setBoardFeet(unsigned boardFeet)
{
    _board_feet = boardFeet;
}

void Hardwood::setWoodType(Hardwood::Wood_Type type)
{
    _wood_type = type;
}

Hardwood::Wood_Type Hardwood::getWoodType() const
{
    return _wood_type;
}

unsigned Hardwood::getBoardFeet() const
{
    return quantity();
}

void Hardwood::display(ostream &os) const
{
    Lumber::display(os);
    string ht[4] = { "Unknown", "Oak", "Maple", "Birch" };
    os << "Hardwood type: " << ht[_wood_type] << endl
       << "Board feet: " << quantity() << endl;
}

float Hardwood::gross_profit() const
{
    switch (_wood_type) {
        case Oak:
            return 0.15 * get_cost() * quantity();

        case Maple:
            return 0.18 * get_cost() * quantity();

        case Birch:
            return 0.125 * get_cost() * quantity();

        default:
            return 0;
    }
}

unsigned Hardwood::quantity() const
{
    return _board_feet;
}
------------------------------------------------------
//Hardwood.h
#ifndef HARDWOOD_H
#define HARDWOOD_H

#include "Lumber.h"

class Hardwood : public Lumber
{
public:
    enum Wood_Type { WTunknown, Oak, Maple, Birch};

    Hardwood();
    Hardwood(Hardwood::Wood_Type, float);
    Hardwood(string, Date, float);
    Hardwood(string, Date, float, string*, unsigned);
    Hardwood(string, Date, float, Hardwood::Wood_Type, float);
    ~Hardwood();

    void setBoardFeet(unsigned);
    void setWoodType(Hardwood::Wood_Type);

    Hardwood::Wood_Type getWoodType() const;
    unsigned getBoardFeet() const;

    virtual void display(ostream &) const;
    virtual float gross_profit() const;
    virtual unsigned quantity() const;

private:
    Hardwood::Wood_Type _wood_type;
    unsigned _board_feet;
};

#endif
----------------------------------------------------------
//Hinge.cpp
#include "Hinge.h"

Hinge::Hinge()
        :Hardware()
{
    _hinge_type = Hinge::HTunknown;
    Hardware::setMaterialType(Hardware::Copper);
    _pieces = 2;
}

Hinge::Hinge(Hinge::Hinge_Type type, float cost)
        :Hardware()
{
    setHingeType(type);
    set_cost(cost);
    Hardware::setMaterialType(Hardware::Copper);
    _pieces = 2;
}

Hinge::Hinge(string upc, Date purchased, float cost)
        :Hardware(upc, purchased, cost, Hardware::Copper, 1)
{
    _hinge_type = Hinge::HTunknown;
    _pieces = 2;
}

Hinge::Hinge(string upc, Date purchased, float cost, string* suppliers, unsigned num_suppliers)
        :Hardware(upc, purchased, cost, suppliers, num_suppliers)
{
    _hinge_type = Hinge::HTunknown;
    Hardware::setMaterialType(Hardware::Copper);
    _pieces = 2;
}

Hinge::Hinge(string upc, Date purchased, float cost, Hinge_Type ht, float wt)
        :Hardware(upc, purchased, cost, Hardware::Copper, 1)
{
    _hinge_type = ht;
    _pieces = 2;
}

Hinge::~Hinge()
{

}

void Hinge::setQuantity(unsigned quantity)
{
    _pieces = quantity;
}

void Hinge::setHingeType(Hinge::Hinge_Type type)
{
    _hinge_type = type;
}

Hinge::Hinge_Type Hinge::getHingeType() const
{
    return _hinge_type;
}

void Hinge::display(ostream &os) const
{
    Hardware::display(os);
    string ht[4] = { "Unknown", "Butt", "Overlay", "Offset" };
    os << "Hinge type: " << ht[_hinge_type] << endl
       << "Pieces: " << quantity() << endl;
}

float Hinge::gross_profit() const
{
    return 0.125 * get_cost() * quantity();
}

unsigned Hinge::quantity() const
{
    return _pieces;
}
--------------------------------------------------
//Hinge.h
#ifndef HINGE_H
#define HINGE_H

#include "Hardware.h"

class Hinge : public Hardware
{
public:
    enum Hinge_Type { HTunknown, Butt, Overlay, Offset};

    Hinge();
    Hinge(Hinge::Hinge_Type, float);
    Hinge(string, Date, float);
    Hinge(string, Date, float, string*, unsigned);
    Hinge(string, Date, float, Hinge::Hinge_Type, float);
    ~Hinge();

    void setQuantity(unsigned);
    void setHingeType(Hinge::Hinge_Type);

    Hinge::Hinge_Type getHingeType() const;

    virtual void display(ostream &) const;
    virtual float gross_profit() const;
    virtual unsigned quantity() const;

private:
    Hinge::Hinge_Type _hinge_type;
    unsigned _pieces;
};

#endif

--------------------------------------------------------------
//Lumbar.cpp

#include "Lumber.h"

Lumber::Lumber()
        :Inventory()
{
    _surfacing_type = Lumber::STunknown;
}

Lumber::Lumber(string upc, Date purchased, float cost, string *suppliers, unsigned numSuppliers)
        :Inventory(upc, purchased, cost, suppliers, numSuppliers)
{
    _surfacing_type = Lumber::STunknown;
}

Lumber::Lumber(string upc, Date purchased, float cost, Lumber::Surfacing_Type type, unsigned inStock)
        :Inventory(upc, purchased, cost)
{
    _surfacing_type = type;
    _inStock = inStock;
}

Lumber::~Lumber()
{

}

void Lumber::setSurfacingType(Lumber::Surfacing_Type type)
{
    _surfacing_type = type;
}

void Lumber::setInStock(unsigned inStock)
{
    _inStock = inStock;
}

Lumber::Surfacing_Type Lumber::getSurfacingType() const
{
    return _surfacing_type;
}

unsigned Lumber::getInStock() const
{
    return _inStock;
}

void Lumber::display(ostream &os) const
{
    Inventory::display(os);

    string type[4] = { "Unknown", "Rough", "S2S", "S4S" };
    os << "Material: " << type[_surfacing_type] << endl;
}

unsigned Lumber::quantity() const
{
    return _inStock;
}


-------------------------------------------------------

//Lumbar.h
#ifndef LUMBER_H
#define LUMBER_H

#include "Inventory.h"

class Lumber : public Inventory
{
public:
    enum Surfacing_Type { STunknown, Rough, S2S, S4S };

    Lumber();
    Lumber(string, Date, float, string * = NULL, unsigned = 0);
    Lumber(string, Date, float, Lumber::Surfacing_Type, unsigned);
    ~Lumber();

    void setSurfacingType(Lumber::Surfacing_Type);
    void setInStock(unsigned);

    Lumber::Surfacing_Type getSurfacingType() const;
    unsigned getInStock() const;

    virtual void display(ostream &) const;
    virtual unsigned quantity() const;

private:
    Lumber::Surfacing_Type _surfacing_type;
    unsigned _inStock;
};

#endif
----------------------------------------------------------
//Pipe.cpp
#include "Pipe.h"

Pipe::Pipe()
        :Inventory()
{
    _diameter = 0;
    _length = 0;
    _material = Pipe::PTunknown;
}

Pipe::Pipe(string upc, Date purchased, float cost,
           string* sp, unsigned ns)
        :Inventory(upc, purchased, cost, sp, ns)
{
    _diameter = 0;
    _length = 0;
    _material = Pipe::PTunknown;
}

Pipe::Pipe(string upc, Date purchased, float cost,
           float dia, float len, Pipe::Material_Type pmt, unsigned ins )
        :Inventory(upc, purchased, cost)
{
    _diameter = dia;
    _length = len;
    _material = pmt;
    _in_stock = ins;
    assert ( _diameter >= 0.0 );
    assert ( _length >= 0.0 );
    assert ( pmt <= Iron );
}
Pipe::~Pipe()
{
}

void Pipe::set_diameter( float dia )
{
    _diameter = dia;
    assert ( _diameter >= 0.0 );
}

void Pipe::set_length( float len )
{
    _length = len;
    assert ( _length >= 0.0 );
}
void Pipe::set_material_type (Pipe::Material_Type pmt)
{
    _material = pmt;
    assert(pmt <= Iron);
}
void Pipe::set_in_stock ( unsigned ins )
{
    _in_stock = ins;
}

float Pipe::get_diamter ( void )const
{
    return _diameter;
}
float Pipe::get_length ( void ) const
{
    return _length;
}

Pipe::Material_Type Pipe::get_material_type ( ) const
{
    return _material;
}

unsigned Pipe::get_in_stock ( ) const
{
    return _in_stock;
}

void Pipe::display( ostream& os ) const
{
    Inventory::display(os);
    os << "Diameter:         " << _diameter<<""" << endl
       << "Length:           " << _length<<"'"<<endl;
    string pmt[4] = {"Unknown", "Plastic", "Copper","Iron" };
    os << "Material:         " << pmt[_material] << endl;
}

unsigned Pipe::quantity ( ) const
{
    return _in_stock * _length;
}
-------------------------------------------------
//Pipe.h
#ifndef PIPE_H
#define PIPE_H

#include "Inventory.h"


class Pipe : public Inventory
{

public:

    enum Material_Type {PTunknown,Plastic,Copper,Iron};

    Pipe();
    Pipe(string, Date, float, string* = NULL, unsigned = 0);
    Pipe(string, Date, float, float, float,
         Pipe::Material_Type, unsigned );
    ~Pipe();

    void set_diameter( float );
    void set_length( float );
    void set_material_type ( Pipe::Material_Type );
    void set_in_stock ( unsigned );

    float get_diamter ( void )const;
    float get_length ( void ) const;
    Pipe::Material_Type get_material_type ( void ) const;
    unsigned get_in_stock ( void ) const;
    virtual void display( ostream& ) const;

    unsigned quantity() const;

private:
    float                _diameter;
    float                _length;
    Pipe::Material_Type _material;
    unsigned             _in_stock;

};
#endif


-----------------------------------------------------------
//Plstic.cpp
#include "Plastic.h"
#include "Pipe.h"

Plastic::Plastic()
        :Pipe()
{
    _material = Plastic::Unknown;
    _wall_thickness = 0.0;
    Pipe::set_material_type(Pipe::Plastic);
}

Plastic::Plastic(string upc, Date purchased, float cost,
                 string* suppliers, unsigned num_suppliers)
        :Pipe(upc,purchased,cost,suppliers,num_suppliers)
{
    _material = Plastic::Unknown;
    _wall_thickness = 0.0;
    Pipe::set_material_type(Pipe::Plastic);
}

Plastic::Plastic(string upc, Date purchased, float cost)
        :Pipe(upc, purchased, cost,0.0,0.0,Pipe::Plastic,1)
{
    _material = Plastic::Unknown;
    _wall_thickness = 0.0;
}

Plastic::Plastic(string upc, Date purchased, float cost,
                 float dia, float len)
        :Pipe(upc, purchased, cost,dia,len,Pipe::Plastic,1)
{
    _material = Plastic::Unknown;
    _wall_thickness = 0.0;
}

Plastic::Plastic(string upc, Date purchased, float cost,
                 float dia, float len, Material_Type pmt ,float wt)
        :Pipe(upc, purchased, cost,dia,len,Pipe::Plastic,1)
{
    _material = pmt;
    _wall_thickness = wt;
}

Plastic::~Plastic(){}

void Plastic::display( ostream& os) const
{
    Pipe::display(os);
    string pt[4] = {"Unknown", "ABS", "PVC", "CPVC" };
    os << "Plastic type:     " << pt[_material]<<endl
       << "Wall Thickness:   " << _wall_thickness <<"""<< endl;;

}

float Plastic::gross_profit ( ) const
{

    float price_per_ft[4] = { 0.0, .5, .75, 1 };
    return get_length() * price_per_ft[_material] - get_length()*get_cost();;
}
--------------------------------------------------------
//Plastic.h
#ifndef PLASTIC_H
#define PLASTIC_H

#include "Pipe.h"


class Plastic : public Pipe
{
public:

    enum Material_Type {Unknown,ABS,PVC,CPVC};

    Plastic();
    Plastic(string, Date, float);
    Plastic(string, Date, float, string*, unsigned);
    Plastic(string, Date, float, float, float);
    Plastic(string, Date, float, float, float,
            Plastic::Material_Type,float);

    ~Plastic();

    void display( ostream& ) const;
    float gross_profit ( ) const;

private:
    Plastic::Material_Type _material;
    float                  _wall_thickness;


};
#endif
---------------------------------------------------------------
//Inventory.h
#include <iostream>
#include "Date.h"
#include <iomanip>
#include <cstdlib>
using namespace std;

#ifndef Inventory_H
#define Inventory_H

class Inventory
{
    string   _UPC;
    Date     _purchased;
    float    _cost;
    string* _suppliers;
    unsigned _num_suppliers;
public:

    Inventory();
    Inventory( string, Date, float, string* = NULL, unsigned = 0 );

    virtual ~Inventory();

    // set functions
    void set_UPC ( string );
    void set_date_purchased ( const Date& );
    void set_cost ( float );


    //get functions
    string get_UPC () const;
    Date get_date_purchased () const;
    float get_cost () const;

    string operator[]( unsigned ) const; // get supplier
    string& operator[] ( unsigned ); // set supplier

    virtual void display( ostream& ) const;
    virtual float selling_price ( ) const;

    virtual float gross_profit ( ) const = 0;
    virtual unsigned quantity()const = 0;

};
#endif
---------------------------------------------------------------------
//Date.h
#ifndef DATE_H
#define DATE_H
#include <iostream>
#include <cstdlib>
#include <cassert>
using namespace std;

enum DATE_CHANGE {MONTH, DAY, YEAR};
enum DATE_STYLE {MM_DD_YYYY, MON_DD_YYYY, DD_MM_YYYY, D_ROM_YYYY};


class Date
{
    unsigned date;
    DATE_STYLE ds;
    unsigned days_in_month()const;
    void set_date(unsigned m, unsigned d, unsigned y );
    void set_day(unsigned);
    void set_month(unsigned);
    void set_year(unsigned);

public:
    Date();
    Date ( unsigned m, unsigned d, unsigned y );
    Date ( const Date& );
    Date& operator= ( const Date& );
    Date& operator+= ( DATE_CHANGE );
    Date& operator-= ( DATE_CHANGE );
    Date operator+ ( DATE_CHANGE ) const;
    Date operator- ( DATE_CHANGE ) const;
    int operator- ( const Date& ) const;

    Date operator++ (int);
    Date& operator++ ( );
    Date operator-- (int);
    Date& operator-- ( );

    bool is_leap_year() const;


    inline void set_date_style( DATE_STYLE DS ) { ds = DS;}

    friend ostream& operator<< ( ostream&, const Date& );
    friend istream& operator>> ( istream&, Date& );

    unsigned month()const;
    unsigned day()const;
    unsigned year()const;
    bool IsPalindrome()const;
    bool operator== ( const Date& )const;
    bool operator!= ( const Date& ) const;
    bool operator> ( const Date& ) const;
    bool operator< ( const Date& ) const;
    bool operator>= ( const Date& ) const;
    bool operator<= ( const Date& ) const;

    bool weekday ( ) const; //returns true if the day is Monday - Friday

};

#endif