c++ - Issue With My School Assignment on Classes -


so have assignment due in c++ class on classes, , i'm having trouble. here description of assignment:

programming challenge 7 on page 499 of text asks design , inventory class can hold information item in retail store's inventory. given code creation of class along code implementation of functions. demonstrate class writing simple program uses it. program should demonstrate each function works correctly. submit .cpp file using link provided.

and here contents of file sent (it's quite lengthy):

// chapter 7---files programming challenge 13---inventory class  // inventory.h file. // contains inventory class declaration.  #ifndef inventory_h #define inventory_h  class inventory { private:     int itemnumber;     int quantity;     double cost;     double totalcost; public:     // default constructor     inventory()         { itemnumber = quantity = cost = totalcost = 0; }      // overloaded constructor     inventory(int, int, double);    // defined in inventory.cpp      // mutators (i.e., "set" functions) defined in inventory.cpp     void setitemnumber(int);     void setquantity(int);     void setcost(double);      // settotalcost calculates total cost     // , stores result in totalcost member     void settotalcost()         { totalcost = cost * quantity; }      // accessors (i.e., "get" functions)     int getitemnumber()         { return itemnumber; }     int getquantity()         { return quantity; }     double getcost()         { return cost; }     double gettotalcost()         { return totalcost; }      // input validation functions     bool validint(int);     bool validfloat(double); };  #endif  // inventory.cpp file. // contains inventory class function definitions.   #include <iostream> #include "inventory.h" using namespace std;  //************************************************************ // overloaded constructor // accepts arguments stored in each member variable. //************************************************************ inventory::inventory(int in, int q, double c) {      setitemnumber(in);     setquantity(q);     setcost(c);     settotalcost(); }  //************************************************************ // setitemnumber accepts argument stored in item number. //************************************************************ void inventory::setitemnumber(int in) {     while (!validint(in))     {         cout << "item number must positive. please re-enter: ";         cin  >> in;     }     itemnumber = in;  }  //************************************************************ // setquantity accepts argument stored in quantity. //************************************************************ void inventory::setquantity(int q) {     while (!validint(q))     {         cout << "quantity must positive. please re-enter: ";         cin  >> q;     }     quantity = q;  }  //************************************************************ // setcost accepts argument stored in cost. //************************************************************ void inventory::setcost(double c) {     while (!validint(c))     {         cout << "cost must positive. please re-enter: ";         cin  >> c;     }     cost = c;  }  //************************************************************ // validint member tests integer argument see  // if negative. if argument negative, function  // returns false. otherwise, function returns true. //************************************************************ bool inventory::validint(int value) {     if (value < 0)    // value negative not valid         return false;     else              // integer value valid         return true;   }  //************************************************************ // validfloat member tests floating-point argument see // if negative. if argument negative, function  // returns false. otherwise, function returns true. //************************************************************ bool inventory::validfloat(double value) {     if (value < 0)    // value negative not valid         return false;     else              // floating-point value valid         return true; } 

i'm not sure how use information make program demonstrates class, , simple me not saving file correct way

just write main function instantiates inventory object , calls each of methods in meaningful way. isn't puzzle, find way call functions makes sense you.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -