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

Dear all Would you please help me with this homework assignment using c++ langua

ID: 3732794 • Letter: D

Question

Dear all

Would you please help me with this homework assignment using c++ language

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:

InventoryHardware

Fastener

Hinge

Lumber

Hardwood

Softwood

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

  

Explanation / Answer

main.cpp


#include "Store.h"

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

return 0;
}

Date.h


#ifndef DATE_H_DEF_
#define DATE_H_DEF_
#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

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

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;
}

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

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;
}

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

Inventory.h

#include <iostream>
#include "Date.h"
#include <iomanip>
#include <cstdlib>
using namespace std;

#ifndef Inventory_H_CISP_400_
#define Inventory_H_CISP_400_

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

Lumber.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;
}
Lumber.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

NOTE:Due to limited characters cant able to post all files.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote