/////////////////////////////////////////////////////////////////////////////// // Equipment.H // // CMSC341 Fall 2001 - Project 1 // // Kyu Bae 212-04-5868 Section 201 // // kyu_bae@yahoo.com / kbae1@umbc.edu // // created: 1 September 2001 // // current: 10 September 2001 // /////////////////////////////////////////////////////////////////////////////// #ifndef _EQUIPMENTGOODS_H #define _EQUIPMENTGOODS_H #include "string.H" /////////////////////////////////////////////////////////////////////////////// // EquipmentGoods Class: // EquipmentGoods carries its type and its weight. This will be kept in vector // container. This class is able to copy another same object with copy // constructor and have equal operator to compare for the dame object. // It has a print idiom and output operator to print its data members. // Author: kyu bae // Version: 12 september 2001 /////////////////////////////////////////////////////////////////////////////// class EquipmentGoods { public: /////////////////////////////////////////////////////////////////////////// // default constructor: // initialize type and wieght to zero. //////////////////////////////////////////////////////////////////////////// EquipmentGoods(); /////////////////////////////////////////////////////////////////////////// // constructor with two arguement: // initialize type to _type and wieght to _weight. // Param type: type of string class is assigned to _type // Param weight: weight of integer is assigned to _weight //////////////////////////////////////////////////////////////////////////// EquipmentGoods(string type, int weight); /////////////////////////////////////////////////////////////////////////// // copy constructor: // copy another EquipmentGoods object to this // Param rhs: another EquipmentGoods to copy /////////////////////////////////////////////////////////////////////////// EquipmentGoods(const EquipmentGoods & rhs); /////////////////////////////////////////////////////////////////////////// // Destructor: /////////////////////////////////////////////////////////////////////////// ~EquipmentGoods(); /////////////////////////////////////////////////////////////////////////// // Assignment operator: // assign eq to this EquipmentGoods // Param eq: eq is the EquipmentGoods to assign the rvalue // Return: this EquipmentGoods after assigning the data members /////////////////////////////////////////////////////////////////////////// const EquipmentGoods& operator= ( const EquipmentGoods & eg); /////////////////////////////////////////////////////////////////////////// // print(): // prints two data members, _type and _weight. this is called by output // operator. // Param out: out ostream's object to write and call output operator /////////////////////////////////////////////////////////////////////////// void print (ostream &out) const; /////////////////////////////////////////////////////////////////////////// // Equal operator: // compare object of EquipmentGoods if they are same item. // Param e1: e1 is object of EquimentGoods to compare // Return: boolean /////////////////////////////////////////////////////////////////////////// bool operator == (const EquipmentGoods &e1) const; private: string _type; int _weight; }; ///////////////////////////////////////////////////////////////////////// // output operator: // this calls print function. // Param out: out the stream to which to write rEqu // Param rEqu: rEqu is Object of Equipment to write // return: ostream ///////////////////////////////////////////////////////////////////////// ostream & operator << (ostream &out, const EquipmentGoods &rEqu); #endif