Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My previous code: ItemToPurchase.h #ifndef ITEMTOPURCHASE_H #define ITEMTOPURCHASE_H #include #include using namespace std; class ItemToPurchase { public: ItemToPurchase(); void SetName(string name); string GetName(); void SetPrice(int

image text in transcribed image text in transcribed image text in transcribed image text in transcribed image text in transcribed image text in transcribed image text in transcribed image text in transcribed

My previous code:

ItemToPurchase.h

#ifndef ITEMTOPURCHASE_H #define ITEMTOPURCHASE_H

#include #include

using namespace std;

class ItemToPurchase { public: ItemToPurchase(); void SetName(string name); string GetName(); void SetPrice(int price); int GetPrice(); void SetQuantity(int quantity); int GetQuantity();

private: string itemName; int itemPrice; int itemQuantity; }; #endif

ItemToPurchase.cpp

#include "ItemToPurchase.h" #include

using namespace std;

ItemToPurchase::ItemToPurchase() { itemName = ""; itemPrice = 0; itemQuantity = 0; }

string ItemToPurchase::GetName() { return itemName; }

int ItemToPurchase::GetPrice() { return itemPrice; }

int ItemToPurchase::GetQuantity() { return itemQuantity; }

void ItemToPurchase::SetName(string name) { itemName = name; }

void ItemToPurchase::SetPrice(int price) { itemPrice = price; }

void ItemToPurchase::SetQuantity(int quantity) { itemQuantity = quantity; }

main.cpp

#include "ItemToPurchase.h" #include

using namespace std;

int main() { ItemToPurchase item, item2; int price, quantity; string name;

cout

cout

cout > price;

cout > quantity;

item.SetName(name); item.SetPrice(price); item.SetQuantity(quantity); cin.ignore();

cout

cout

cout

cout > price;

cout > quantity;

item2.SetName(name); item2.SetPrice(price); item2.SetQuantity(quantity);

cout

cout

cin.get(); cin.get(); }

17.19 Ch 7 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 . SetDescription0 mutator & GetDescription0 accessor (2 pts) PrintitemCost0-Outputs the item name followed by the quantity, price, and subtotal PrintltemDescription0 - Outputs the item name and description Private data members string itemDescription - Initialized in default constructor to "none" Ex. of PrintitemCost0 output Bottled Water 10 $1 $10 Ex. of PrintltemDescription0 output: Bottled Water Deer Park, 12 oz

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL For Data Science Data Cleaning Wrangling And Analytics With Relational Databases

Authors: Antonio Badia

1st Edition

3030575918, 978-3030575915

More Books

Students also viewed these Databases questions

Question

3. Job rotation is used for all levels and types of employees.

Answered: 1 week ago