/* Filename: product2.cpp Author: Br. David Carlson Date: March 18, 2017 This file implements the Product class that was set up in product2.h. */ #include "product2.h" /* Given: InitialName A string containing the product name. InitialYear The year this product was made. InitialPrice The product's price. Task: This is the default constructor. It creates a new Product object containing the 3 items listed above. Return: Nothing is directly returned, but the object is created. */ Product::Product(string InitialName, int InitialYear, double InitialPrice) { Year = InitialYear; Price = InitialPrice; Name = InitialName; // Just so that you can see when the constructor is called: cout << "Constructor called for object with name " << InitialName << endl; } /* Given: Nothing other than the implicit object. Task: This is the destructor. It destroys the implicit object, reclaiming all of the space that it used. Return: Nothing. */ Product::~Product(void) { // Print a message just so that you can see when the destructor gets called: cout << "Destructor called for product named " << Name << endl; } /* Given: Nothing (other than the implicit object). Task: To print the data contained in this object. Return: Nothing. */ void Product::Print(void) const { cout << "Product name: " << Name << endl << "Year made: " << Year << endl << "Price: " << Price << endl << endl; } /* Given: NameValue A string. Task: To place NameValue into the Name field of the implicit object. Return: Nothing directly, though the implicit object is updated. */ void Product::SetName(string NameValue) { Name = NameValue; } /* Given: YearValue An integer representing a year. Task: To place YearValue into the Year field of the implicit object. Return: Nothing directly, though the implicit object is updated. */ void Product::SetYear(int YearValue) { Year = YearValue; } /* Given: PriceValue A float representing a monetary amount. Task: To place PriceValue into the Price field of the implicit object. Return: Nothing directly, though the implicit object is updated. */ void Product::SetPrice(double PriceValue) { Price = PriceValue; } /* Given: Nothing other than the implicit object. Task: To look up the value of the Name field of the implicit object. Return: This Name field value in the function name. */ string Product::GetName(void) const { return Name; } /* Given: Nothing other than the implicit object. Task: To look up the value of the Year field of the implicit object. Return: This Year field value in the function name. */ int Product::GetYear(void) const { return Year; } /* Given: Nothing other than the implicit object. Task: To look up the value of the Price field of the implicit object. Return: This Price field value in the function name. */ double Product::GetPrice(void) const { return Price; }