/*

  InventoryRecord.cpp

  Componants: InventoryRecord.h, FuncList.h, InventoryRecord.cpp, FuncList.cpp, Try.cpp

  Author: Ahmad Mobasseri

*/

 

#include <iostream>

#include <string>

using namespace std;

 

class InventoryItem

{

      string itemID;

      string itemDesc;

public:

      InventoryItem() {itemID=""; itemDesc="";}

      // Mutators

      void setID   (string ID)   {itemID = ID;}

      void setDesc (string Desc) {itemDesc = Desc;}

      // Accessors

      string getID()   {return itemID;}

      string getDesc() {return itemDesc;}

};

 

class InventoryRecord : public InventoryItem

{

      double UnitCost;

      long   NumberInStock;

      string Location;

public:

      InventoryRecord() {UnitCost=0; NumberInStock=0; string Location="";}

      // Mutators

      void setCost  (double Cost) {UnitCost = Cost;}

      void setStock (long Stock)  {NumberInStock = Stock;}

      void setLoc   (string Loc)  {Location = Loc;}

      // Accessors

      double getCost()  {return UnitCost;}

      long   getStock() {return NumberInStock;}

      string getLoc()   {return Location;}

         

  bool equals(string ID);

  bool operator>(InventoryRecord&);

  bool operator==(InventoryRecord&);

  bool operator==(string);

};

 

bool InventoryRecord::operator >(InventoryRecord& Ref)

{

  if( this->getID() > Ref.getID() )

    return true;

  return false;

}

 

bool InventoryRecord::operator==(InventoryRecord& Ref)

{

  if( this->getID() == Ref.getID() )

    return true;

  return false;

}

 

bool InventoryRecord::operator==(string Ref)

{

  if( this->getID() == Ref)

    return true;

  return false;

}

 

bool InventoryRecord::equals(string Ref)

{

  if( this->getID() == Ref)

    return true;

  return false;

}

 

 

//Overload output/write operator to be used in display ViewList, FindList, WriteList functions.

ostream& operator<<(ostream& S, InventoryRecord Ref)

{

   return S << Ref.getID() << " " << Ref.getDesc() << " "

              << Ref.getCost() << " " << Ref.getStock() << " " << Ref.getLoc();

}

 

 

//Overload input/read operator to be used in getting input data in AddList function.

istream& operator>>(istream& S, InventoryRecord& Ref)

{

   string ID, Desc, Loc; double Cost; long Stock;

  

   cout << "Enter Item ID: ";

   S  >> ID;                              // NOTE: can use "cin"  or "S"

   if (ID == "Stop")

   {

         Ref.setID(ID);

         return S;

   }

 

   cout << "Enter Desc: ";

   S  >> Desc;

  

   cout << "Enter Location: ";

   cin  >> Loc;

  

   cout << "Enter Unit Cost: ";

   cin  >> Cost;

 

   cout << "Enter Number in Stock: ";

   S  >> Stock;

  

   Ref.setID(ID);

   Ref.setDesc(Desc);

   Ref.setLoc(Loc);

   Ref.setCost(Cost);

   Ref.setStock(Stock);

  

   return S;

 }