// Project 2 for CS 1704 Spring II 2004 // // Programmer: Mason Shea // OS: Windows XP // System: Pentium III 500, 256 MB Memory // Compiler: Visual C++ 6.0, Service Pack 4 // Last modified: February 25, 2004 // // Purpose // The purpose of this file is to describe the implementation for the data type // item, in other words, it contains the implementation for all the previously // declared member functions of the Item class #include "items.h" //default constructor which sets all the data fields to defaults values Item::Item() { myItem = "nothing"; myMediaType = "nothing"; myBy = "nothing"; myOwner = "nothing"; myPrice = 0.0; myAvailability = "nothing"; } //constructor here gets sent all the data fields and assigns them accordingly Item::Item(string Title, string MediaType, string By, string Owner, double Price, string Availability) { setItem(Title); setMediaType(MediaType); setBy(By); setOwner(Owner); setPrice(Price); setAvailability(Availability); } //copy constructor get sent an item and assigns that item's info to the current item Item::Item(const Item &item) { myItem = item.myItem; myMediaType = item.myMediaType; myBy = item.myBy; myOwner = item.myOwner; myPrice = item.myPrice; myAvailability = item.myAvailability; } //these are the mutator operations, they set the current item's data field equal to the data field sent to it void Item::setItem(string Title) { myItem = Title; } void Item::setMediaType(string MediaType) { myMediaType = MediaType; } void Item::setBy(string By) { myBy = By; } void Item::setOwner(string Owner) { myOwner = Owner; } void Item::setPrice(double Price) { myPrice = Price; } void Item::setAvailability(string Availability) { myAvailability = Availability; } //these are accessor operations; they only return the given item's particular data field string Item::getItem() const { return myItem; } string Item::getMediaType() const { return myMediaType; } string Item::getBy() const { return myBy; } string Item::getOwner() const { return myOwner; } double Item::getPrice() const { return myPrice; } string Item::getAvailability() const { return myAvailability; } //this is the overloaded assignment operator =, which when sent an item copies that student's info into the current item's info (is this mimicking the copy constructor??) Item& Item::operator=(const Item& item) { if(this != &item) { myItem = item.myItem; myMediaType = item.myMediaType; myBy = item.myBy; myOwner = item.myOwner; myPrice = item.myPrice; myAvailability = item.myAvailability; } return *this; }