title: Issue With My School Assignment on Classes
body: <p>So I have an assignment due in my C++ class on classes, and I'm having some trouble. Here is the description of the assignment:</p>
  
  <p>Programming Challenge 7 on page 499 of your text asks you to design and Inventory Class that can hold information for an item in a retail store's inventory. You are given the code for the creation of the class along with code for the implementation of the functions. Demonstrate the class by writing a simple program that uses it. This program should demonstrate that each function works correctly. Submit your .cpp file using the link provided.</p>
  
  <p>And here are the contents of the file sent (it's quite lengthy):</p>
  
  <pre><code>// Chapter 7---Files for Programming Challenge 13---Inventory Class
  
  // This is the inventory.h file.
  // It contains the 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 the total cost
      // and stores the result in the 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
  
  // This is the inventory.cpp file.
  // It contains the Inventory class function definitions. 
  
  #include &lt;iostream&gt;
  #include "Inventory.h"
  using namespace std;
  
  //************************************************************
  // Overloaded constructor
  // Accepts arguments to be stored in each member variable.
  //************************************************************
  Inventory::Inventory(int in, int q, double c)
  { 
      setItemNumber(in);
      setQuantity(q);
      setCost(c);
      setTotalCost();
  }
  
  //************************************************************
  // setItemNumber accepts an argument to be stored in item number.
  //************************************************************
  void Inventory::setItemNumber(int in)
  {
      while (!validInt(in))
      {
          cout &lt;&lt; "Item Number must be positive. Please re-enter: ";
          cin  &gt;&gt; in;
      }
      itemNumber = in; 
  }
  
  //************************************************************
  // setQuantity accepts an argument to be stored in quantity.
  //************************************************************
  void Inventory::setQuantity(int q)
  {
      while (!validInt(q))
      {
          cout &lt;&lt; "Quantity must be positive. Please re-enter: ";
          cin  &gt;&gt; q;
      }
      quantity = q; 
  }
  
  //************************************************************
  // setCost accepts an argument to be stored in cost.
  //************************************************************
  void Inventory::setCost(double c)
  {
      while (!validInt(c))
      {
          cout &lt;&lt; "Cost must be positive. Please re-enter: ";
          cin  &gt;&gt; c;
      }
      cost = c; 
  }
  
  //************************************************************
  // The validInt member tests its integer argument to see 
  // if it is negative. If the argument is negative, the function 
  // returns false. Otherwise, the function returns true.
  //************************************************************
  bool Inventory::validInt(int value)
  {
      if (value &lt; 0)    // the value is negative so it is NOT valid
          return false;
      else              // the integer value is valid
          return true;  
  }
  
  //************************************************************
  // The validFloat member tests its floating-point argument to see
  // if it is negative. If the argument is negative, the function 
  // returns false. Otherwise, the function returns true.
  //************************************************************
  bool Inventory::validFloat(double value)
  {
      if (value &lt; 0)    // the value is negative so it is NOT valid
          return false;
      else              // the floating-point value is valid
          return true;
  }
  </code></pre>
  
  <p>I'm just not sure how to use this information to make a program that demonstrates the class, and it could be as simple as me not saving the file the correct way</p>