/* Filename: product2.cpp Author: Br. David Carlson Date: July 5, 1998 Revised: July 17, 2000 Revised: July 27,2006 for use in a Windows Forms App example. This file implements the Product class that was set up in product2.h. */ #include "stdafx.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(ShortString InitialName, int InitialYear, double InitialPrice) { // Recall that you cannot simply assign one string into another. strcpy(Name, InitialName); Year = InitialYear; Price = InitialPrice; } /* Given: NewPrice A new price to use for the implicit Product object. Task: To change the price of this object to NewPrice. Return: Nothing directly, but the Product object is modified. */ void Product::ChangePrice(double NewPrice) { Price = NewPrice; } /* Given: Nothing. Task: To look up the name of the implicit Product object. Return: ProductName The name of this Product object. */ void Product::GetName(ShortString ProductName) const { // Once again, you cannot use assignment with strings. strcpy(ProductName, Name); } /* Given: Nothing. Task: To look up the year the implicit Product object was made. Return: This year in the function name. */ int Product::GetYear(void) const { return Year; } /* Given: Nothing. Task: To look up the price of the implicit Product object. Return: The price of this Product object, in the function name. */ double Product::GetPrice(void) const { return Price; }