Good::Good(const char* u, const char* n, double p, int q, bool t) { upc(u); name(n); price(p); qtyNeeded(q); taxed(t); quantity(0); }
// Copy Constructor Good::Good(const Good& other) { upc(other._upc); name(other._name); price(other._price); qtyNeeded(other._qtyNeeded); taxed(other._taxed); quantity(other._quantity); }
// operator= Item& Item::operator=(const Item& RO){ upc(RO._upc); name(RO._name); price(RO._price); quantity(RO._quantity); taxed(RO._taxed); qtyNeeded(RO._qtyNeeded); return *this; }
Product::Product(const char* s, const char* n, double x, int i, bool tax) { // Copies the SKU into the corresponding member variable up to MAX_SKU_LEN characters. //still hae to implement as just does (strcpy(x,y)) right now sku(s); name(n); price(x); qtyNeeded(i); quantity(0); taxed(tax); }
// Assignment Operator= Good& Good::operator=(const Good& other) { if (this != &other) { upc(other._upc); name(other._name); price(other._price); qtyNeeded(other._qtyNeeded); taxed(other._taxed); quantity(other._quantity); } return *this; }
//copy con Product::Product(const Product& other) { // sku(other.sku_); name(other.name_); price(other.price_); taxed(other.taxed_); quantity(other.quantity_); qtyNeeded(other.qtyNeeded_); }
Product& Product::operator=(const Product& other) { //may not need to test this if (this != &other) { sku(other.sku_); name(other.name_); price(other.price_); taxed(other.taxed_); quantity(other.quantity_); qtyNeeded(other.qtyNeeded_); } return *this; }
//================================================== // copyFromSource // // This function deeps copy data from the source into this object. Can be used for copy constructor and // assignment operators //================================================== Good& Good::copyFromSource (const Good& source) { char tmpUpc [MAX_UPC_LEN + 1]; char tmpName [2000]; strncpy (tmpUpc, source.upc (), MAX_UPC_LEN); strncpy (tmpName, source.name (), 2000); upc (tmpUpc); name (tmpName); price (source.price ()); quantity (source.quantity ()); taxed (source.taxed ()); qtyNeeded (source.qtyNeeded ()); return *this; }
const double Item::cost()const{ return (taxed()) ? price() + price()*TAX : price(); }
double Good::cost () const { return (taxed ()) ? price () * ( TAX + 1) : price () ; }