SlideShare a Scribd company logo
1 of 13
Download to read offline
I have the first program completed (not how request, but it works) and I am trying to get the
second portion together.
First Program requested (complete)**********************************************
(1) Create three files to submit:
ItemToPurchase.h - Class declaration
ItemToPurchase.cpp - Class definition
main.cpp - main() function
Build the ItemToPurchase class with the following specifications:
Default constructor
Public class functions (mutators & accessors)
SetName() & GetName() (2 pts)
SetPrice() & GetPrice() (2 pts)
SetQuantity() & GetQuantity() (2 pts)
Private data members
string itemName - Initialized in default constructor to "none"
int itemPrice - Initialized in default constructor to 0
int itemQuantity - Initialized in default constructor to 0
(2) In main(), prompt the user for two items and create two objects of the ItemToPurchase class.
Before prompting for the second item, call cin.ignore() to allow the user to input a new string. (2
pts)
Ex:
(3) Add the costs of the two items together and output the total cost. (2 pts)
Ex:
Second Portion I am on
now**************************************************************************
*******
7.19 Program: Online shopping cart (continued) (C++)
This program extends the earlier "Online shopping cart" program. (Consider first saving your
earlier program).
(1) Extend the ItemToPurchase class per the following specifications:
Parameterized constructor to assign item name, item description, item price, and item quantity
(default values of 0). (1 pt)
Public member functions
SetDescription() mutator & GetDescription() accessor (2 pts)
PrintItemCost() - Outputs the item name followed by the quantity, price, and subtotal
PrintItemDescription() - Outputs the item name and description
Private data members
string itemDescription - Initialized in default constructor to "none"
Ex. of PrintItemCost() output:
Ex. of PrintItemDescription() output:
(2) Create three new files:
ShoppingCart.h - Class declaration
ShoppingCart.cpp - Class definition
main.cpp - main() function (Note: main()'s functionality differs from the warm up)
Build the ShoppingCart class with the following specifications. Note: Some can be function
stubs (empty functions) initially, to be completed in later steps.
Default constructor
Parameterized constructor which takes the customer name and date as parameters (1 pt)
Private data members
string customerName - Initialized in default constructor to "none"
string currentDate - Initialized in default constructor to "January 1, 2016"
vector < ItemToPurchase > cartItems
Public member functions
GetCustomerName() accessor (1 pt)
GetDate() accessor (1 pt)
AddItem()
Adds an item to cartItems vector. Has parameter ItemToPurchase. Does not return anything.
RemoveItem()
Removes item from cartItems vector. Has a string (an item's name) parameter. Does not return
anything.
If item name cannot be found, output this message: Item not found in cart. Nothing removed.
ModifyItem()
Modifies an item's description, price, and/or quantity. Has parameter ItemToPurchase. Does not
return anything.
If item can be found (by name) in cart, check if parameter has default values for description,
price, and quantity. If not, modify item in cart.
If item cannot be found (by name) in cart, output this message: Item not found in cart. Nothing
modified.
GetNumItemsInCart() (2 pts)
Returns quantity of all items in cart. Has no parameters.
GetCostOfCart() (2 pts)
Determines and returns the total cost of items in cart. Has no parameters.
PrintTotal()
Outputs total of objects in cart.
If cart is empty, output this message: SHOPPING CART IS EMPTY
PrintDescriptions()
Outputs each item's description.
Ex. of PrintTotal() output:
Ex. of PrintDescriptions() output:
(3) In main(), prompt the user for a customer's name and today's date. Output the name and
date. Create an object of type ShoppingCart. (1 pt)
Ex.
(4) Implement the PrintMenu() function. PrintMenu() has a ShoppingCart parameter, and
outputs a menu of options to manipulate the shopping cart. Each option is represented by a single
character. Build and output the menu within the function.
If the an invalid character is entered, continue to prompt for a valid choice. Hint: Implement Quit
before implementing other options. Call PrintMenu() in the main() function. Continue to execute
the menu until the user enters q to Quit. (3 pts)
Ex:
(5) Implement Output shopping cart menu option. (3 pts)
Ex:
(6) Implement Output item's description menu option. (2 pts)
Ex.
(7) Implement Add item to cart menu option. (3 pts)
Ex:
(8) Implement remove item menu option. (4 pts)
Ex:
(9) Implement Change item quantity menu option. Hint: Make new ItemToPurchase object and
use ItemToPurchase modifiers before using ModifyItem() function. (5 pts)
Ex:
My Program to start second
portion************************************************************************
***********************
main.cpp**********************************************************************
****************
#include
#include
#include
using namespace std;
#include "ItemToPurchase.h"
#include "ShoppingCart.h"
void PrintMenu()
{
char userKey = '?';
cout << "MENU" << endl;
cout << "a - Add item to cart" << endl;
cout << "d - Remove item from cart" << endl;
cout << "c - Change item quantity" << endl;
cout << "i - Output items' descriptions" << endl;
cout << "o - Output shopping cart" << endl;
cout << "q - Quit" << endl << endl;
while (userKey != 'q')
{
cout << "Choose an option: ";
cin >> userKey;
if (userKey == 'a' || userKey == 'A')
{
cout << "A selected" << endl;
}
else if (userKey == 'd' || userKey == 'D')
{
cout << "D selected" << endl;
}
else if (userKey == 'c' || userKey == 'C')
{
cout << "C selected" << endl;
}
else if (userKey == 'i' || userKey == 'I')
{
cout << "I selected" << endl;
}
else if (userKey == 'o' || userKey == 'O')
{
cout << "O selected" << endl;
}
else if (userKey == 'q' || userKey == 'Q')
{
cout << "Q selected" << endl;
userKey = 'q';
}
else if (userKey != 'q')
{
cout << "Invalid Choice, please choose a valid option." << endl;
}
}
return;
}
int main()
{
// ShoppingCart cart;
string customerName, todaysDate;
cout << "Enter Customer's Name: ";
getline(cin, customerName);
cout << endl << "Enter Today's Date: ";
getline(cin, todaysDate);
cout << endl << "Customer Name: " << customerName << endl;
cout << "Today's Date: " << todaysDate << endl;
PrintMenu();
return 0;
}
ShoppingCart.h*****************************************************************
*********************
#pragma once
#ifndef ShoppingCart_h
#define ShoppingCart_h
class ShoppingCart {
public:
ShoppingCart();
string GetCustomerName();// accessor(1 pt)
string GetDate();// accessor(1 pt)
void AddItem();// Adds an item to cartItems vector.Has parameter ItemToPurchase.Does not
return anything.
void RemoveItem(); // Removes item from cartItems vector.Has a string(an item's name)
parameter. Does not return anything.
//If item name cannot be found, output this message: Item not found in cart.Nothing removed.
void ModifyItem(); // Modifies an item's description, price, and/or quantity. Has parameter
ItemToPurchase. Does not return anything.
//If item can be found(by name) in cart, check if parameter has default values for description,
price, and quantity.If not, modify item in cart.
//If item cannot be found(by name) in cart, output this message : Item not found in cart.Nothing
modified.
int GetNumItemsInCart(); //(2 pts) Returns quantity of all items in cart.Has no parameters.
int GetCostOfCart();// (2 pts) Determines and returns the total cost of items in cart.Has no
parameters.
void PrintTotal(); // Outputs total of objects in cart.
//If cart is empty, output this message: SHOPPING CART IS EMPTY
void PrintDescriptions();// Outputs each item's description
private:
string customerName;
string currentDate;
vector cartItems;
};
#endif
ShoppingCart.cpp***************************************************************
***********************
#include
#include
#include
#include "ShoppingCart.h"
using namespace std;
ShoppingCart::ShoppingCart() //default constructor
{
customerName = "none";
currentDate = "January 1, 2016";
return;
}
string ShoppingCart::GetCustomerName()
{
return customerName;
}
string ShoppingCart::GetDate()
{
return todaysDate;
}
void ShoppingCart::AddItem()// Adds an item to cartItems vector.Has parameter
ItemToPurchase.Does not return anything.
{
return;
}
void ShoppingCart::RemoveItem()// Removes item from cartItems vector.Has a string(an item's
name) parameter. Does not return anything.
{
//cout << "Item not found in cart. Nothing removed." << endl;
return;
}
void ShoppingCart::ModifyItem() // Modifies an item's description, price, and/or quantity. Has
parameter ItemToPurchase. Does not return anything. If item can be found(by name) in cart,
check if parameter has default values for description, price, and quantity.If not, modify item in
cart. If item cannot be found(by name) in cart, output this message : Item not found in
cart.Nothing modified.
{
return;
}
int ShoppingCart::GetNumItemsInCart() //(2 pts) Returns quantity of all items in cart.Has no
parameters.
{
return numItems;
}
int ShoppingCart::GetCostOfCart()// (2 pts) Determines and returns the total cost of items in
cart.Has no parameters.
{
return costOfCart;
}
void ShoppingCart::PrintTotal() // Outputs total of objects in cart.
{
//cout << "SHOPPING CART IS EMPTY" << endl;
return;
}
void ShoppingCart::PrintDescriptions()// Outputs each item's description
{
// int i;
// i = 0;
// while (i < sizeofvector)
// {
//
// ++i;
// }
return;
}
ItemToPurchase.h***************************************************************
***********************
#pragma once
#ifndef ItemToPurchase_h
#define ItemToPurchase_h
class ItemToPurchase {
public:
ItemToPurchase();
string SetName(string resitemName);
string GetName(string resitemName);
int SetPrice(int resitemPrice);
int GetPrice(int resitemPrice);
int SetQuantity(int resitemQuantity);
int GetQuantity(int resitemQuantity);
void SetDescription();
void GetDescription();
void PrintItemCost();
void PrintItemDescription();
void PrintTotal();
void Reserve(string resitemName, int resitemPrice, int resitemQuantity);
void Print() const;
void testPrint();
private:
string itemName;
string itemDescription;
int itemPrice;
int itemQuantity;
int combinedTotal;
};
#endif
ItemToPurchase.cpp*************************************************************
*************************
#include
#include
#include
using namespace std;
#include "ItemToPurchase.h"
ItemToPurchase::ItemToPurchase() //default constructor
{
itemName = "NoName"; //default name
itemPrice = -1; //default price
itemQuantity = -1; //default qty
itemDescription = "None";
combinedTotal = 0; //default total
return;
}
string ItemToPurchase::SetName(string resitemName)
{
itemName = resitemName;
return itemName;
}
string ItemToPurchase::GetName(string resitemName)
{
itemName = resitemName;
return itemName;
}
int ItemToPurchase::SetPrice(int resitemPrice)
{
itemPrice = resitemPrice;
return itemPrice;
}
int ItemToPurchase::GetPrice(int resitemPrice)
{
itemPrice = resitemPrice;
return itemPrice;
}
int ItemToPurchase::SetQuantity(int resitemQuantity)
{
itemQuantity = resitemQuantity;
return itemQuantity;
}
int ItemToPurchase::GetQuantity(int resitemQuantity)
{
itemQuantity = resitemQuantity;
return itemQuantity;
}
void ItemToPurchase::SetDescription()
{
return;
}
void ItemToPurchase::GetDescription()
{
return;
}
void ItemToPurchase::PrintItemCost() //Outputs the item name followed by the quantity, price,
and subtotal
{
return;
}
void ItemToPurchase::PrintItemDescription() //Outputs the item name and description
{
return;
}
//the below should have been through the above functions
void ItemToPurchase::Reserve(string resitemName, int resitemPrice, int resitemQuantity)
{
itemName = resitemName;
itemPrice = resitemPrice;
itemQuantity = resitemQuantity;
return;
}
void ItemToPurchase::Print() const
{
int unitTotal;
unitTotal = itemQuantity * itemPrice;
cout << itemName << " " << itemQuantity << " @ $" << itemPrice << " = $" << unitTotal
<< endl;
return;
}
void ItemToPurchase::PrintTotal()
{
cout << "Total: $" << combinedTotal << endl;
}
void ItemToPurchase::testPrint()
{
cout << itemName << endl << itemPrice << endl << itemQuantity << endl << endl;
return;
}
Solution
#include "stdafx.h"
#include "ShopKeeper.h"
#include "Player.h"
#include
void PurchaseItem(Player& plyr)
{
int responce = 0;
std::cout << "1: Mace - 30 gold. 2: Bow - 50 gold. 3: Boots - 10 gold. 4: Bearskin - 75 gold. 5:
Helmet - 25 gold." << " ";
do
{
std::cin >> responce;
switch (responce)
{
case 1:
plyr.AddItem("Mace", 30);
break;
case 2:
plyr.AddItem("Bow", 50);
break;
case 3:
plyr.AddItem("Boots", 10);
break;
case 4:
plyr.AddItem("Bearskin", 75);
break;
case 5:
plyr.AddItem("Helmet", 25);
break;
default:
std::cout << "Please enter valid data." << " ";
std::cout << "1: Mace - 30 gold. 2: Bow - 50 gold. 3: Boots - 10 gold. 4: Bearskin - 75 gold. 5:
Helmet - 25 gold." << " ";
}
} while (responce > 5 || responce < 1);
}

More Related Content

Similar to I have the first program completed (not how request, but it works) a.pdf

filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxssuser454af01
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법Jeado Ko
 
please code in c#- please note that im a complete beginner- northwind.docx
please code in c#- please note that im a complete beginner-  northwind.docxplease code in c#- please note that im a complete beginner-  northwind.docx
please code in c#- please note that im a complete beginner- northwind.docxAustinaGRPaigey
 
show code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdfshow code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdfAlanSmDDyerl
 
Use of Classes and functions#include iostreamusing name.docx
 Use of Classes and functions#include iostreamusing name.docx Use of Classes and functions#include iostreamusing name.docx
Use of Classes and functions#include iostreamusing name.docxaryan532920
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overviewstn_tkiller
 
For the following questions, you will implement the data structure to.pdf
For the following questions, you will implement the data structure to.pdfFor the following questions, you will implement the data structure to.pdf
For the following questions, you will implement the data structure to.pdfarjunhassan8
 
I keep on get a redefinition error and an undefined error.Customer.pdf
I keep on get a redefinition error and an undefined error.Customer.pdfI keep on get a redefinition error and an undefined error.Customer.pdf
I keep on get a redefinition error and an undefined error.Customer.pdfherminaherman
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfpnaran46
 
Whats new in ES2019
Whats new in ES2019Whats new in ES2019
Whats new in ES2019chayanikaa
 
Program Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxProgram Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxVictormxrPiperc
 
This is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdfThis is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdfindiaartz
 
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdfUsing c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdffashiongallery1
 
Hey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdfHey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdfforwardcom41
 
Qtp Training Deepti 3 Of 44256
Qtp Training Deepti 3 Of 44256Qtp Training Deepti 3 Of 44256
Qtp Training Deepti 3 Of 44256Azhar Satti
 

Similar to I have the first program completed (not how request, but it works) a.pdf (20)

filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docxfilesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
filesHeap.h#ifndef HEAP_H#define HEAP_H#includ.docx
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
 
please code in c#- please note that im a complete beginner- northwind.docx
please code in c#- please note that im a complete beginner-  northwind.docxplease code in c#- please note that im a complete beginner-  northwind.docx
please code in c#- please note that im a complete beginner- northwind.docx
 
show code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdfshow code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdf
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
Use of Classes and functions#include iostreamusing name.docx
 Use of Classes and functions#include iostreamusing name.docx Use of Classes and functions#include iostreamusing name.docx
Use of Classes and functions#include iostreamusing name.docx
 
Gift-VT Tools Development Overview
Gift-VT Tools Development OverviewGift-VT Tools Development Overview
Gift-VT Tools Development Overview
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 
For the following questions, you will implement the data structure to.pdf
For the following questions, you will implement the data structure to.pdfFor the following questions, you will implement the data structure to.pdf
For the following questions, you will implement the data structure to.pdf
 
I keep on get a redefinition error and an undefined error.Customer.pdf
I keep on get a redefinition error and an undefined error.Customer.pdfI keep on get a redefinition error and an undefined error.Customer.pdf
I keep on get a redefinition error and an undefined error.Customer.pdf
 
I need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdfI need help to modify my code according to the instructions- Modify th.pdf
I need help to modify my code according to the instructions- Modify th.pdf
 
Whats new in ES2019
Whats new in ES2019Whats new in ES2019
Whats new in ES2019
 
Capstone ms2
Capstone ms2Capstone ms2
Capstone ms2
 
Program Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxProgram Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docx
 
Constructor,destructors cpp
Constructor,destructors cppConstructor,destructors cpp
Constructor,destructors cpp
 
This is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdfThis is a C# project . I am expected to create as this image shows. .pdf
This is a C# project . I am expected to create as this image shows. .pdf
 
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdfUsing c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
 
Pro.docx
Pro.docxPro.docx
Pro.docx
 
Hey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdfHey I need help creating this code using Visual Studio (Basic) 2015.pdf
Hey I need help creating this code using Visual Studio (Basic) 2015.pdf
 
Qtp Training Deepti 3 Of 44256
Qtp Training Deepti 3 Of 44256Qtp Training Deepti 3 Of 44256
Qtp Training Deepti 3 Of 44256
 

More from footworld1

Describe 3 functions of the cellular membrane and how are these func.pdf
Describe 3 functions of the cellular membrane and how are these func.pdfDescribe 3 functions of the cellular membrane and how are these func.pdf
Describe 3 functions of the cellular membrane and how are these func.pdffootworld1
 
Discuss the three main types of intellectual capitalSolutionth.pdf
Discuss the three main types of intellectual capitalSolutionth.pdfDiscuss the three main types of intellectual capitalSolutionth.pdf
Discuss the three main types of intellectual capitalSolutionth.pdffootworld1
 
Describer in detail the innate immune response to both an intercellu.pdf
Describer in detail the innate immune response to both an intercellu.pdfDescriber in detail the innate immune response to both an intercellu.pdf
Describer in detail the innate immune response to both an intercellu.pdffootworld1
 
Describe the difference between tropic and non-tropic hormones.S.pdf
Describe the difference between tropic and non-tropic hormones.S.pdfDescribe the difference between tropic and non-tropic hormones.S.pdf
Describe the difference between tropic and non-tropic hormones.S.pdffootworld1
 
C++ ProgrammingGivenWrite a closest Pair FunctionDeliverable.pdf
C++ ProgrammingGivenWrite a closest Pair FunctionDeliverable.pdfC++ ProgrammingGivenWrite a closest Pair FunctionDeliverable.pdf
C++ ProgrammingGivenWrite a closest Pair FunctionDeliverable.pdffootworld1
 
Can someone explain to me what the learning curve equation (Tn=T1n^.pdf
Can someone explain to me what the learning curve equation (Tn=T1n^.pdfCan someone explain to me what the learning curve equation (Tn=T1n^.pdf
Can someone explain to me what the learning curve equation (Tn=T1n^.pdffootworld1
 
Both influenza virus and (IFV), and Measles Virus (MV) are envel.pdf
Both influenza virus and (IFV), and Measles Virus (MV) are envel.pdfBoth influenza virus and (IFV), and Measles Virus (MV) are envel.pdf
Both influenza virus and (IFV), and Measles Virus (MV) are envel.pdffootworld1
 
All of the following are characteristic to fatigue fracture surfaces.pdf
All of the following are characteristic to fatigue fracture surfaces.pdfAll of the following are characteristic to fatigue fracture surfaces.pdf
All of the following are characteristic to fatigue fracture surfaces.pdffootworld1
 
A cancer biology topic Describte how ChIP (chromatin immunoprecipit.pdf
A cancer biology topic Describte how ChIP (chromatin immunoprecipit.pdfA cancer biology topic Describte how ChIP (chromatin immunoprecipit.pdf
A cancer biology topic Describte how ChIP (chromatin immunoprecipit.pdffootworld1
 
You get a call from a customer who reinstalled Windows on his comput.pdf
You get a call from a customer who reinstalled Windows on his comput.pdfYou get a call from a customer who reinstalled Windows on his comput.pdf
You get a call from a customer who reinstalled Windows on his comput.pdffootworld1
 
You are running the Windows installation setup for Windows 7 on a co.pdf
You are running the Windows installation setup for Windows 7 on a co.pdfYou are running the Windows installation setup for Windows 7 on a co.pdf
You are running the Windows installation setup for Windows 7 on a co.pdffootworld1
 
Write a program to decipher messages encoded using a prefix code, gi.pdf
Write a program to decipher messages encoded using a prefix code, gi.pdfWrite a program to decipher messages encoded using a prefix code, gi.pdf
Write a program to decipher messages encoded using a prefix code, gi.pdffootworld1
 
With the biological species concept, the process of speciation is fre.pdf
With the biological species concept, the process of speciation is fre.pdfWith the biological species concept, the process of speciation is fre.pdf
With the biological species concept, the process of speciation is fre.pdffootworld1
 
Write a class ArrayList that represents an array of integers. Init.pdf
Write a class ArrayList that represents an array of integers. Init.pdfWrite a class ArrayList that represents an array of integers. Init.pdf
Write a class ArrayList that represents an array of integers. Init.pdffootworld1
 
what is the relationship between lnx and 1xSolutionThe relat.pdf
what is the relationship between lnx and 1xSolutionThe relat.pdfwhat is the relationship between lnx and 1xSolutionThe relat.pdf
what is the relationship between lnx and 1xSolutionThe relat.pdffootworld1
 
Which of these conclusions is supported by plant phylogenies (evolut.pdf
Which of these conclusions is supported by plant phylogenies (evolut.pdfWhich of these conclusions is supported by plant phylogenies (evolut.pdf
Which of these conclusions is supported by plant phylogenies (evolut.pdffootworld1
 
Who are some other individuals who might want to use the informa.pdf
Who are some other individuals who might want to use the informa.pdfWho are some other individuals who might want to use the informa.pdf
Who are some other individuals who might want to use the informa.pdffootworld1
 
Which account below is not a subdivision of owners equityAccumu.pdf
Which account below is not a subdivision of owners equityAccumu.pdfWhich account below is not a subdivision of owners equityAccumu.pdf
Which account below is not a subdivision of owners equityAccumu.pdffootworld1
 
What is the nucleoid region of a prokaryotic cell a membrane bound .pdf
What is the nucleoid region of a prokaryotic cell  a membrane bound .pdfWhat is the nucleoid region of a prokaryotic cell  a membrane bound .pdf
What is the nucleoid region of a prokaryotic cell a membrane bound .pdffootworld1
 
What is heartwood What is sapwood What is the most abundant tissu.pdf
What is heartwood  What is sapwood  What is the most abundant tissu.pdfWhat is heartwood  What is sapwood  What is the most abundant tissu.pdf
What is heartwood What is sapwood What is the most abundant tissu.pdffootworld1
 

More from footworld1 (20)

Describe 3 functions of the cellular membrane and how are these func.pdf
Describe 3 functions of the cellular membrane and how are these func.pdfDescribe 3 functions of the cellular membrane and how are these func.pdf
Describe 3 functions of the cellular membrane and how are these func.pdf
 
Discuss the three main types of intellectual capitalSolutionth.pdf
Discuss the three main types of intellectual capitalSolutionth.pdfDiscuss the three main types of intellectual capitalSolutionth.pdf
Discuss the three main types of intellectual capitalSolutionth.pdf
 
Describer in detail the innate immune response to both an intercellu.pdf
Describer in detail the innate immune response to both an intercellu.pdfDescriber in detail the innate immune response to both an intercellu.pdf
Describer in detail the innate immune response to both an intercellu.pdf
 
Describe the difference between tropic and non-tropic hormones.S.pdf
Describe the difference between tropic and non-tropic hormones.S.pdfDescribe the difference between tropic and non-tropic hormones.S.pdf
Describe the difference between tropic and non-tropic hormones.S.pdf
 
C++ ProgrammingGivenWrite a closest Pair FunctionDeliverable.pdf
C++ ProgrammingGivenWrite a closest Pair FunctionDeliverable.pdfC++ ProgrammingGivenWrite a closest Pair FunctionDeliverable.pdf
C++ ProgrammingGivenWrite a closest Pair FunctionDeliverable.pdf
 
Can someone explain to me what the learning curve equation (Tn=T1n^.pdf
Can someone explain to me what the learning curve equation (Tn=T1n^.pdfCan someone explain to me what the learning curve equation (Tn=T1n^.pdf
Can someone explain to me what the learning curve equation (Tn=T1n^.pdf
 
Both influenza virus and (IFV), and Measles Virus (MV) are envel.pdf
Both influenza virus and (IFV), and Measles Virus (MV) are envel.pdfBoth influenza virus and (IFV), and Measles Virus (MV) are envel.pdf
Both influenza virus and (IFV), and Measles Virus (MV) are envel.pdf
 
All of the following are characteristic to fatigue fracture surfaces.pdf
All of the following are characteristic to fatigue fracture surfaces.pdfAll of the following are characteristic to fatigue fracture surfaces.pdf
All of the following are characteristic to fatigue fracture surfaces.pdf
 
A cancer biology topic Describte how ChIP (chromatin immunoprecipit.pdf
A cancer biology topic Describte how ChIP (chromatin immunoprecipit.pdfA cancer biology topic Describte how ChIP (chromatin immunoprecipit.pdf
A cancer biology topic Describte how ChIP (chromatin immunoprecipit.pdf
 
You get a call from a customer who reinstalled Windows on his comput.pdf
You get a call from a customer who reinstalled Windows on his comput.pdfYou get a call from a customer who reinstalled Windows on his comput.pdf
You get a call from a customer who reinstalled Windows on his comput.pdf
 
You are running the Windows installation setup for Windows 7 on a co.pdf
You are running the Windows installation setup for Windows 7 on a co.pdfYou are running the Windows installation setup for Windows 7 on a co.pdf
You are running the Windows installation setup for Windows 7 on a co.pdf
 
Write a program to decipher messages encoded using a prefix code, gi.pdf
Write a program to decipher messages encoded using a prefix code, gi.pdfWrite a program to decipher messages encoded using a prefix code, gi.pdf
Write a program to decipher messages encoded using a prefix code, gi.pdf
 
With the biological species concept, the process of speciation is fre.pdf
With the biological species concept, the process of speciation is fre.pdfWith the biological species concept, the process of speciation is fre.pdf
With the biological species concept, the process of speciation is fre.pdf
 
Write a class ArrayList that represents an array of integers. Init.pdf
Write a class ArrayList that represents an array of integers. Init.pdfWrite a class ArrayList that represents an array of integers. Init.pdf
Write a class ArrayList that represents an array of integers. Init.pdf
 
what is the relationship between lnx and 1xSolutionThe relat.pdf
what is the relationship between lnx and 1xSolutionThe relat.pdfwhat is the relationship between lnx and 1xSolutionThe relat.pdf
what is the relationship between lnx and 1xSolutionThe relat.pdf
 
Which of these conclusions is supported by plant phylogenies (evolut.pdf
Which of these conclusions is supported by plant phylogenies (evolut.pdfWhich of these conclusions is supported by plant phylogenies (evolut.pdf
Which of these conclusions is supported by plant phylogenies (evolut.pdf
 
Who are some other individuals who might want to use the informa.pdf
Who are some other individuals who might want to use the informa.pdfWho are some other individuals who might want to use the informa.pdf
Who are some other individuals who might want to use the informa.pdf
 
Which account below is not a subdivision of owners equityAccumu.pdf
Which account below is not a subdivision of owners equityAccumu.pdfWhich account below is not a subdivision of owners equityAccumu.pdf
Which account below is not a subdivision of owners equityAccumu.pdf
 
What is the nucleoid region of a prokaryotic cell a membrane bound .pdf
What is the nucleoid region of a prokaryotic cell  a membrane bound .pdfWhat is the nucleoid region of a prokaryotic cell  a membrane bound .pdf
What is the nucleoid region of a prokaryotic cell a membrane bound .pdf
 
What is heartwood What is sapwood What is the most abundant tissu.pdf
What is heartwood  What is sapwood  What is the most abundant tissu.pdfWhat is heartwood  What is sapwood  What is the most abundant tissu.pdf
What is heartwood What is sapwood What is the most abundant tissu.pdf
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptxPoojaSen20
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
PSYCHIATRIC History collection FORMAT.pptx
PSYCHIATRIC   History collection FORMAT.pptxPSYCHIATRIC   History collection FORMAT.pptx
PSYCHIATRIC History collection FORMAT.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 

I have the first program completed (not how request, but it works) a.pdf

  • 1. I have the first program completed (not how request, but it works) and I am trying to get the second portion together. First Program requested (complete)********************************************** (1) Create three files to submit: ItemToPurchase.h - Class declaration ItemToPurchase.cpp - Class definition main.cpp - main() function Build the ItemToPurchase class with the following specifications: Default constructor Public class functions (mutators & accessors) SetName() & GetName() (2 pts) SetPrice() & GetPrice() (2 pts) SetQuantity() & GetQuantity() (2 pts) Private data members string itemName - Initialized in default constructor to "none" int itemPrice - Initialized in default constructor to 0 int itemQuantity - Initialized in default constructor to 0 (2) In main(), prompt the user for two items and create two objects of the ItemToPurchase class. Before prompting for the second item, call cin.ignore() to allow the user to input a new string. (2 pts) Ex: (3) Add the costs of the two items together and output the total cost. (2 pts) Ex: Second Portion I am on now************************************************************************** ******* 7.19 Program: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt)
  • 2. Public member functions SetDescription() mutator & GetDescription() accessor (2 pts) PrintItemCost() - Outputs the item name followed by the quantity, price, and subtotal PrintItemDescription() - Outputs the item name and description Private data members string itemDescription - Initialized in default constructor to "none" Ex. of PrintItemCost() output: Ex. of PrintItemDescription() output: (2) Create three new files: ShoppingCart.h - Class declaration ShoppingCart.cpp - Class definition main.cpp - main() function (Note: main()'s functionality differs from the warm up) Build the ShoppingCart class with the following specifications. Note: Some can be function stubs (empty functions) initially, to be completed in later steps. Default constructor Parameterized constructor which takes the customer name and date as parameters (1 pt) Private data members string customerName - Initialized in default constructor to "none" string currentDate - Initialized in default constructor to "January 1, 2016" vector < ItemToPurchase > cartItems Public member functions GetCustomerName() accessor (1 pt) GetDate() accessor (1 pt) AddItem() Adds an item to cartItems vector. Has parameter ItemToPurchase. Does not return anything. RemoveItem() Removes item from cartItems vector. Has a string (an item's name) parameter. Does not return anything. If item name cannot be found, output this message: Item not found in cart. Nothing removed. ModifyItem() Modifies an item's description, price, and/or quantity. Has parameter ItemToPurchase. Does not return anything. If item can be found (by name) in cart, check if parameter has default values for description, price, and quantity. If not, modify item in cart.
  • 3. If item cannot be found (by name) in cart, output this message: Item not found in cart. Nothing modified. GetNumItemsInCart() (2 pts) Returns quantity of all items in cart. Has no parameters. GetCostOfCart() (2 pts) Determines and returns the total cost of items in cart. Has no parameters. PrintTotal() Outputs total of objects in cart. If cart is empty, output this message: SHOPPING CART IS EMPTY PrintDescriptions() Outputs each item's description. Ex. of PrintTotal() output: Ex. of PrintDescriptions() output: (3) In main(), prompt the user for a customer's name and today's date. Output the name and date. Create an object of type ShoppingCart. (1 pt) Ex. (4) Implement the PrintMenu() function. PrintMenu() has a ShoppingCart parameter, and outputs a menu of options to manipulate the shopping cart. Each option is represented by a single character. Build and output the menu within the function. If the an invalid character is entered, continue to prompt for a valid choice. Hint: Implement Quit before implementing other options. Call PrintMenu() in the main() function. Continue to execute the menu until the user enters q to Quit. (3 pts) Ex: (5) Implement Output shopping cart menu option. (3 pts) Ex: (6) Implement Output item's description menu option. (2 pts)
  • 4. Ex. (7) Implement Add item to cart menu option. (3 pts) Ex: (8) Implement remove item menu option. (4 pts) Ex: (9) Implement Change item quantity menu option. Hint: Make new ItemToPurchase object and use ItemToPurchase modifiers before using ModifyItem() function. (5 pts) Ex: My Program to start second portion************************************************************************ *********************** main.cpp********************************************************************** **************** #include #include #include using namespace std; #include "ItemToPurchase.h" #include "ShoppingCart.h" void PrintMenu() { char userKey = '?'; cout << "MENU" << endl; cout << "a - Add item to cart" << endl; cout << "d - Remove item from cart" << endl; cout << "c - Change item quantity" << endl; cout << "i - Output items' descriptions" << endl; cout << "o - Output shopping cart" << endl; cout << "q - Quit" << endl << endl; while (userKey != 'q')
  • 5. { cout << "Choose an option: "; cin >> userKey; if (userKey == 'a' || userKey == 'A') { cout << "A selected" << endl; } else if (userKey == 'd' || userKey == 'D') { cout << "D selected" << endl; } else if (userKey == 'c' || userKey == 'C') { cout << "C selected" << endl; } else if (userKey == 'i' || userKey == 'I') { cout << "I selected" << endl; } else if (userKey == 'o' || userKey == 'O') { cout << "O selected" << endl; } else if (userKey == 'q' || userKey == 'Q') { cout << "Q selected" << endl; userKey = 'q'; } else if (userKey != 'q') { cout << "Invalid Choice, please choose a valid option." << endl; } } return; } int main()
  • 6. { // ShoppingCart cart; string customerName, todaysDate; cout << "Enter Customer's Name: "; getline(cin, customerName); cout << endl << "Enter Today's Date: "; getline(cin, todaysDate); cout << endl << "Customer Name: " << customerName << endl; cout << "Today's Date: " << todaysDate << endl; PrintMenu(); return 0; } ShoppingCart.h***************************************************************** ********************* #pragma once #ifndef ShoppingCart_h #define ShoppingCart_h class ShoppingCart { public: ShoppingCart(); string GetCustomerName();// accessor(1 pt) string GetDate();// accessor(1 pt) void AddItem();// Adds an item to cartItems vector.Has parameter ItemToPurchase.Does not return anything. void RemoveItem(); // Removes item from cartItems vector.Has a string(an item's name) parameter. Does not return anything. //If item name cannot be found, output this message: Item not found in cart.Nothing removed. void ModifyItem(); // Modifies an item's description, price, and/or quantity. Has parameter ItemToPurchase. Does not return anything. //If item can be found(by name) in cart, check if parameter has default values for description, price, and quantity.If not, modify item in cart. //If item cannot be found(by name) in cart, output this message : Item not found in cart.Nothing modified. int GetNumItemsInCart(); //(2 pts) Returns quantity of all items in cart.Has no parameters. int GetCostOfCart();// (2 pts) Determines and returns the total cost of items in cart.Has no parameters.
  • 7. void PrintTotal(); // Outputs total of objects in cart. //If cart is empty, output this message: SHOPPING CART IS EMPTY void PrintDescriptions();// Outputs each item's description private: string customerName; string currentDate; vector cartItems; }; #endif ShoppingCart.cpp*************************************************************** *********************** #include #include #include #include "ShoppingCart.h" using namespace std; ShoppingCart::ShoppingCart() //default constructor { customerName = "none"; currentDate = "January 1, 2016"; return; } string ShoppingCart::GetCustomerName() { return customerName; } string ShoppingCart::GetDate() { return todaysDate; } void ShoppingCart::AddItem()// Adds an item to cartItems vector.Has parameter ItemToPurchase.Does not return anything. { return; } void ShoppingCart::RemoveItem()// Removes item from cartItems vector.Has a string(an item's
  • 8. name) parameter. Does not return anything. { //cout << "Item not found in cart. Nothing removed." << endl; return; } void ShoppingCart::ModifyItem() // Modifies an item's description, price, and/or quantity. Has parameter ItemToPurchase. Does not return anything. If item can be found(by name) in cart, check if parameter has default values for description, price, and quantity.If not, modify item in cart. If item cannot be found(by name) in cart, output this message : Item not found in cart.Nothing modified. { return; } int ShoppingCart::GetNumItemsInCart() //(2 pts) Returns quantity of all items in cart.Has no parameters. { return numItems; } int ShoppingCart::GetCostOfCart()// (2 pts) Determines and returns the total cost of items in cart.Has no parameters. { return costOfCart; } void ShoppingCart::PrintTotal() // Outputs total of objects in cart. { //cout << "SHOPPING CART IS EMPTY" << endl; return; } void ShoppingCart::PrintDescriptions()// Outputs each item's description { // int i; // i = 0; // while (i < sizeofvector) // { // // ++i;
  • 9. // } return; } ItemToPurchase.h*************************************************************** *********************** #pragma once #ifndef ItemToPurchase_h #define ItemToPurchase_h class ItemToPurchase { public: ItemToPurchase(); string SetName(string resitemName); string GetName(string resitemName); int SetPrice(int resitemPrice); int GetPrice(int resitemPrice); int SetQuantity(int resitemQuantity); int GetQuantity(int resitemQuantity); void SetDescription(); void GetDescription(); void PrintItemCost(); void PrintItemDescription(); void PrintTotal(); void Reserve(string resitemName, int resitemPrice, int resitemQuantity); void Print() const; void testPrint(); private: string itemName; string itemDescription; int itemPrice; int itemQuantity; int combinedTotal; }; #endif ItemToPurchase.cpp************************************************************* ************************* #include
  • 10. #include #include using namespace std; #include "ItemToPurchase.h" ItemToPurchase::ItemToPurchase() //default constructor { itemName = "NoName"; //default name itemPrice = -1; //default price itemQuantity = -1; //default qty itemDescription = "None"; combinedTotal = 0; //default total return; } string ItemToPurchase::SetName(string resitemName) { itemName = resitemName; return itemName; } string ItemToPurchase::GetName(string resitemName) { itemName = resitemName; return itemName; } int ItemToPurchase::SetPrice(int resitemPrice) { itemPrice = resitemPrice; return itemPrice; } int ItemToPurchase::GetPrice(int resitemPrice) { itemPrice = resitemPrice; return itemPrice; } int ItemToPurchase::SetQuantity(int resitemQuantity) { itemQuantity = resitemQuantity;
  • 11. return itemQuantity; } int ItemToPurchase::GetQuantity(int resitemQuantity) { itemQuantity = resitemQuantity; return itemQuantity; } void ItemToPurchase::SetDescription() { return; } void ItemToPurchase::GetDescription() { return; } void ItemToPurchase::PrintItemCost() //Outputs the item name followed by the quantity, price, and subtotal { return; } void ItemToPurchase::PrintItemDescription() //Outputs the item name and description { return; } //the below should have been through the above functions void ItemToPurchase::Reserve(string resitemName, int resitemPrice, int resitemQuantity) { itemName = resitemName; itemPrice = resitemPrice; itemQuantity = resitemQuantity; return; } void ItemToPurchase::Print() const { int unitTotal;
  • 12. unitTotal = itemQuantity * itemPrice; cout << itemName << " " << itemQuantity << " @ $" << itemPrice << " = $" << unitTotal << endl; return; } void ItemToPurchase::PrintTotal() { cout << "Total: $" << combinedTotal << endl; } void ItemToPurchase::testPrint() { cout << itemName << endl << itemPrice << endl << itemQuantity << endl << endl; return; } Solution #include "stdafx.h" #include "ShopKeeper.h" #include "Player.h" #include void PurchaseItem(Player& plyr) { int responce = 0; std::cout << "1: Mace - 30 gold. 2: Bow - 50 gold. 3: Boots - 10 gold. 4: Bearskin - 75 gold. 5: Helmet - 25 gold." << " "; do { std::cin >> responce; switch (responce) { case 1: plyr.AddItem("Mace", 30); break;
  • 13. case 2: plyr.AddItem("Bow", 50); break; case 3: plyr.AddItem("Boots", 10); break; case 4: plyr.AddItem("Bearskin", 75); break; case 5: plyr.AddItem("Helmet", 25); break; default: std::cout << "Please enter valid data." << " "; std::cout << "1: Mace - 30 gold. 2: Bow - 50 gold. 3: Boots - 10 gold. 4: Bearskin - 75 gold. 5: Helmet - 25 gold." << " "; } } while (responce > 5 || responce < 1); }