Question

In: Computer Science

C++.This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1)...

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:

Bottled Water 10 @ $1 = $10


Ex. of PrintItemDescription() output:

Bottled Water: Deer Park, 12 oz.


(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:

John Doe's Shopping Cart - February 1, 2016

Number of Items: 8

Nike Romaleos 2 @ $189 = $378

Total: $


Ex. of PrintDescriptions() output:

John Doe's Shopping Cart - February 1, 2016

Item Descriptions

Nike Romaleos: Volt color, Weightlifting shoes

Chocolate Chips: Semi-sweet

Powerbeats 2 Headphones: Bluetooth headphones


(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)


(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:

MENU

a - Add item to cart

d - Remove item from cart

c - Change item quantity

i - Output items' descriptions

o - Output shopping cart

q - Quit

Choose an option:


(5) Implement Output shopping cart menu option. (3 pts)

Ex:

OUTPUT SHOPPING CART

John Doe's Shopping Cart - February 1, 2016

Number of Items: 8

Nike Romaleos 2 @ $189 = $378

Total:


(6) Implement Output item's description menu option. (2 pts)

Ex.

OUTPUT ITEMS' DESCRIPTIONS

John Doe's Shopping Cart - February 1, 2016

Item Descriptions

Nike Romaleos: Volt color, Weightlifting shoes

Chocolate Chips: Semi-sweet

Powerbeats 2 Headphones: Bluetooth headphones


(7) Implement Add item to cart menu option. (3 pts)

Ex:

ADD ITEM TO CART

Enter the item name:

Nike Romaleos

Enter the item description:

Volt color, Weightlifting shoes

Enter the item price:

189

Enter the item quantity:

2


(8) Implement remove item menu option. (4 pts)

Ex:

REMOVE ITEM FROM CART

Enter name of item to remove:

Chocolate Chips


(9) Implement Change item quantity menu option. Hint: Make new ItemToPurchase object and use ItemToPurchase modifiers before using ModifyItem() function. (5 pts)

Ex:

CHANGE ITEM QUANTITY

Enter the item name:

Nike Romaleos

Enter the new quantity:

3


Here’s what I have (the main file needs to be completed).
***ItemToPurchase.cpp
#include "ItemToPurchase.h"
//Implementation of default constructor
ItemToPurchase::ItemToPurchase()
{
itemName = "0";
itemPrice = 0;
itemQuantity = 0;
description = "0";
}
ItemToPurchase::ItemToPurchase(string itemName, int itemPrice, int itemQuanity, string description){
this->itemName = itemName;
this->itemPrice = itemPrice;
this->itemQuanity = itemQuantity;
this->description = description;
}
//Implementation of SetName function
void ItemToPurchase::SetName(string name)
{
itemName = name;
}
//Implementation of SetPrice function
void ItemToPurchase::SetPrice(int itemP)
{
itemPrice = itemP;
}
//Implementation of SetQuantity function
void ItemToPurchase::SetQuantity(int itemQ)
{
itemQuantity = itemQ;
}
void ItemToPurchase::setDescription(string description){
this-> description = description;
}
//Implementation of GetName function
string ItemToPurchase::GetName()
{
return itemName;
}
//Implementation of GetPrice function
int ItemToPurchase::GetPrice()
{
return itemPrice;
}
//Implementation of GetQuantity function
int ItemToPurchase::GetQuantity()
{
return itemQuantity;
}
string ItemToPurchase::getDescription(){
return description;
}
***ItemtoPurchase.h
#pragma once
#ifndef ITEMTOPURCHASE_H_INCLUDED
#define ITEMTOPURCHASE_H_INCLUDED
#include<string>
#include <iostream>
using namespace std;
class ItemToPurchase
{
public:
//Declaration of default constructor
ItemToPurchase();
ItemToPurchase(string itemName, int itemPrice, int itemQuanity, string description);
//Declaration of SetName function
void SetName(string itemName);
//Declaration of SetPrice function
void SetPrice(int itemPrice);
//Declaration of SetQuantity function
void SetQuantity(int itemQuantity);
//Declaration of GetName function
string GetName();
//Declaration of GetPrice function
int GetPrice();
//Declaration of GetQuantity function
int GetQuantity();
string GetDescription();
void setDescription(string itemDescription);
void printItemCost();
void printItemDescription();
private:
//Declaration of itemName as
//type of string
string itemName;
//Declaration of itemPrice as
//type of integer
int itemPrice;
//Declaration of itemQuantity as
//type of integer
int itemQuantity;
string description;
};
#endif
***ShoppingCart.cpp
#include"ShoppingCart.h"
#include<stdbool.h>
#include<iostream>
//Implementation of GetCustomerName function
string ShoppingCart::GetCustomerName()
{
return this->customerName;
}
//Implementation of GetDate function
string ShoppingCart::GetDate()
{
return this->currentDate;
}
//Implementation of AddItem function
void ShoppingCart::AddItem(ItemToPurchase addnewitem)
{
for (int i=0; i < this->cartItems.size(); i++){
if (this->cartItems.at(i).getName() == addnewitem.getName()){
this->cartItems.at(i).setQuantity(this->cartItems.at(i).getQuanity() + addnewitem.getQuanity);
return;
}
}
this->cartItems.push_back(addnewitem);
}
//Implementation of RemoveItem function
void ShoppingCart::RemoveItem(string itemName)
{
//bool found = false;
//Iterate the loop
for (int i = 0; i < this->cartItems.size(); i++)
{   
if (this->cartItems.at(i).getName() == itemName)
{
//found = true;
this->cartItems.erase(cartItems.begin() + i);
return;
}
}
cout << endl << "Item not found in cart. Nothing removed." << endl << endl;
}
//Implementation of ModifyItem function
//with parameter is ItemToPurchase
void ShoppingCart::ModifyItem(ItemToPurchase itemToModify) {
int i = 0;
//Iterate the loop
while (i < cartItems.size()) {
//check cartItems name is equal to name of the modified item
if (cartItems.at(i).getName() == itemToModify.getName()) {
//cartItems.at(i).quantity = itemToModify.quantity;
//get quanity
if (itemToModify.getQuanity() != 0){
cartItems.at(i).setQuantity(itemToModify.getQuanity());
}
//get price
if (itemToModify.getPrice() != 0){
cartItems.at(i).setPrice(itemToModify.getPrice());
}
// get description
if (itemToModify.getDescription() != 0){
carItems.at(i).setDescription(itemToModify.getDescription();
}
return;
}
i++;
}
cout << endl << "Item not found in cart. Nothing modified." << endl << endl;
}
//Implementation of GetNumItemsInCart function
int ShoppingCart::GetNumItemsInCart()
{
int counter = 0;
for (int i = 0; i < this-> cartItems.size(); i++){
counter += this-> cartItems.at(i).getQuanity();
}
return counter;
}
//Implementation of GetCostOfCart function
int ShoppingCart::GetCostOfCart()
{
int totalCost = 0;
  
//Iterate the loop
for (int i = 0; i < this->cartItems.size(); i++)
{
//calculate the totalCost
totalCost += this->cartItems.at(i).price * this->cartItems.at(i).quantity;
}
return totalCost;
}
//Implementation of PrintTotal function
void ShoppingCart::PrintTotal()
{
if (this->cartItems.size() == 0)
{
//Display statement
cout << "SHPPING CART IS EMPTY" << endl;
}
else
{
//Display statement
cout << this->customerName << "'s Shopping Cart - " << this->currentDate << endl << endl;
//Display statement
cout << "Number of Items: " << this->cartItems.size() << endl << endl;
//Iterate the loop
for (int i = 0; i < this->cartItems.size(); i++)
{
this->cartItems.at(i).PrintItemCost();
cout << endl;
}
//Display statement
cout << endl << "Total: $" << this->GetCostOfCart() << endl << endl;
}
}
//Implemenataion of PrintDescriptions function
void ShoppingCart::PrintDescriptions()
{
//Display statement
cout << this->customerName << "'s Shopping Cart - " << this->currentDate << endl << endl;
cout << endl;
//Display statement
cout << "Item Descriptions" << endl << endl;
//Iterate the loop
for (int i = 0; i < this->cartItems.size(); i++)
{
this->cartItems.at(i).PrintItemDescription();
cout << endl;
}
}
***ShoppingCart.h
#pragma once
#include<vector>
#include<string>
#include"ItemToPurchase.h"
using namespace std;
//Declaration of ShoppingCart class
class ShoppingCart {
private:
//Declare customerName as type of string
string customerName;
//Declare currentDate as type of string
string currentDate;
//Declare carItems as type of ItemToPurchase
vector<ItemToPurchase> cartItems;
public:
//Implementation of default constructor
ShoppingCart()
{
this->customerName = "none";
this->currentDate = "October 1, 2020";
}
//Implementation of parameterized constructor
ShoppingCart(string customerName, string currentDate)
{
this->customerName = customerName;
this->currentDate = currentDate;
}
//Declaration GetCustomerName function
string GetCustomerName();
//Declaration of GetDate function
string GetDate();
//Declaration of AddItem function
void AddItem(ItemToPurchase addnewitem);
//Declaration of RemoveItem function
void RemoveItem(string itemName);
//Declaration of GetNumItemsInCart function
int GetNumItemsInCart();
//Declaration of GetCostOfCart function
int GetCostOfCart();
//Declaration of PrintTotal function
void PrintTotal();
//Declaration of PrintDescriptions function
void PrintDescriptions();
//Declaration of ModifyItem function
//which has paramter ItemToPurchase
void ModifyItem(ItemToPurchase);
};

Solutions

Expert Solution

main.cpp
----------------------------------------------------------------------------
#include <iostream>
#include <string>
#include "ItemToPurchase.h"
#include "ShoppingCart.h"

using namespace std;

void AddItem(ShoppingCart &cart) {
ItemToPurchase addItem;
string addItemName;
string addItemDescription;
int addItemPrice;
int addItemQuantity;
cout << endl << "ADD ITEM TO CART";
cout << endl << "Enter the item name: ";
cin.ignore();
getline(cin, addItemName);
addItem.SetName(addItemName);
cout << endl << "Enter the item description: ";
getline(cin, addItemDescription);
addItem.SetDescription(addItemDescription);
cout << endl << "Enter the item price: ";
cin >> addItemPrice;
addItem.SetPrice(addItemPrice);
cout << endl << "Enter the item quantity: ";
cin >> addItemQuantity;
addItem.SetQuantity(addItemQuantity);
cart.AddItem(addItem);

}

void RemoveItem(ShoppingCart &cart) {
string removeItem;

cout << endl << "REMOVE ITEM FROM CART";
cout << endl << "Enter name of item to remove: ";
cin.ignore();
getline(cin, removeItem);
cart.RemoveItem(removeItem);
}

void ChangeItemQuantity(ShoppingCart &cart) {
string changeQuantityItem;
int changeQuantityNumber;

cout << endl << "CHANGE ITEM QUANTITY";
cout << endl << "Enter the item name: ";
cin.ignore();
getline(cin, changeQuantityItem);
cout << endl << "Enter the new quantity: ";
cin >> changeQuantityNumber;
cart.UpdateQuantity(changeQuantityItem, changeQuantityNumber);
}

void OutputItemsDescriptions(ShoppingCart cart, string customerName, string todaysDate) {
cout << "OUTPUT ITEMS' DESCRIPTIONS";
cout << endl << customerName << "'s Shopping Cart - " << todaysDate;
cout << endl;
cart.PrintDescriptions();
}

void OutputShoppingCart(ShoppingCart cart, string customerName, string todaysDate) {
cout << endl << "OUTPUT SHOPPING CART";
cout << endl << customerName << "'s Shopping Cart - " << todaysDate;
cout << endl;
cart.PrintTotal();
}

void PrintMenu(ShoppingCart cart) {
string customerName;
string todaysDate;
char userOption = '1';

cout << "Enter Customer's Name: ";
getline(cin, customerName);
cout << endl << "Enter Today's Date: ";
getline(cin, todaysDate);
cout << endl << "Customer Name: " << customerName;
cout << endl << "Today's Date: " << todaysDate;

do {
cout << endl << "MENU" << endl << "a - Add item to cart" << endl << "d - Remove item from cart" << endl
<< "c - Change item quantity" << endl << "i - Output items\' descriptions" << endl << "o - Output shopping cart"
<< endl << "q - Quit" << endl;
do {
cout << endl << "Choose an option: ";
cin >> userOption;
if (cin.fail()) {
cin.clear();
cin.ignore('\n', 1000);
return;
}
} while (userOption != 'a' && userOption != 'd' && userOption != 'c' && userOption != 'i' && userOption != 'o' && userOption != 'q');
if (userOption == 'a') {
AddItem(cart);
}
else if (userOption == 'd') {
RemoveItem(cart);
}
else if (userOption == 'c') {
ChangeItemQuantity(cart);
}
else if (userOption == 'i') {
OutputItemsDescriptions(cart, customerName, todaysDate);
}
else if (userOption == 'o') {
OutputShoppingCart(cart, customerName, todaysDate);
}
} while (userOption != 'q');
}


int main() {


ShoppingCart cart;
PrintMenu(cart);

return 0;
}
---------------------------------------------------------------------------------------------------------
ShoppingCart.cpp
--------------------------------------------------------
#include "ShoppingCart.h"

ShoppingCart::ShoppingCart()
{
customerName = "none";
currentDate = "January 1, 2016";
}

ShoppingCart::ShoppingCart(string name, string date)
{
customerName = name;
currentDate = date;
}


ShoppingCart::~ShoppingCart()
{
}

string ShoppingCart::GetCustomerName()
{
return customerName;
}

string ShoppingCart::GetDate()
{
return currentDate;
}

void ShoppingCart::AddItem(ItemToPurchase item)
{
this->cartItems.push_back(item);
}

void ShoppingCart::RemoveItem(string itemName)
{
//this->cartItems.erase(find(cartItems.begin(), cartItems.end(), itemName));
for (int i = 0; i < cartItems.size(); i++) {
if (this->cartItems.at(i).GetName() == itemName) {
this->cartItems.erase(cartItems.begin() + i);
return;
}
}
cout << endl << "Item not found in cart. Nothing removed.";
}

void ShoppingCart::UpdateQuantity(string itemName, int newQuantity)
{
for (int i = 0; i < cartItems.size(); i++) {
if (this->cartItems.at(i).GetName() == itemName) {
cartItems.at(i).SetQuantity(newQuantity);
return;
}
}
cout << endl << "Item not found in cart. Nothing modified.";
}

int ShoppingCart::GetNumItemsInCart()
{
int numItems = 0;
for (int i = 0; i < cartItems.size(); i++) {
numItems += cartItems.at(i).GetQuantity();
}
return numItems;
}

int ShoppingCart::GetCostOfCart()
{
int totalCost = 0;
for (int i = 0; i < cartItems.size(); i++) {
totalCost += (cartItems.at(i).GetPrice() * cartItems.at(i).GetQuantity());
}
return totalCost;
}

void ShoppingCart::PrintTotal()
{

cout << "Number of Items: " << GetNumItemsInCart();
for (int i = 0; i < cartItems.size(); i++) {
cout << endl << cartItems.at(i).GetName() << " " << cartItems.at(i).GetQuantity() << " @ $" << cartItems.at(i).GetPrice()
<< " = $" << (cartItems.at(i).GetQuantity() * cartItems.at(i).GetPrice());
}
if (cartItems.size() == 0) {
cout << endl << endl << "SHOPPING CART IS EMPTY";
}
cout << endl << endl << "Total: $" << GetCostOfCart();
}

void ShoppingCart::PrintDescriptions()
{
cout << endl << "Item Descriptions";
for (int i = 0; i < cartItems.size(); i++) {
cout << endl << cartItems.at(i).GetName() << ": " << cartItems.at(i).GetDescription();
}
}
----------------------------------------------------------------------------------------------------------------------------------------
ShoppingCart.h
--------------------------------------------------------------------
#pragma once
#include <string>
#include "ItemToPurchase.h"
#include <vector>
#include <iostream>

using namespace std;

class ShoppingCart
{
private:
string customerName;
string currentDate;
vector <ItemToPurchase> cartItems;

public:
ShoppingCart();
ShoppingCart(string name, string date);
~ShoppingCart();
string GetCustomerName();
string GetDate();
void AddItem(ItemToPurchase item);
void RemoveItem(string itemName);
void UpdateQuantity(string itemname, int newQuantity);
int GetNumItemsInCart();
int GetCostOfCart();
void PrintTotal();
void PrintDescriptions();
};
-----------------------------------------------------------------------------------------------------------------------
ItemToPurchase.cpp
-------------------------------------------------------------------------
#include "ItemToPurchase.h"
#include <iostream>

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

ItemToPurchase::ItemToPurchase(string name, string description, int price, int quantity)
{
itemName = name;
itemDescription = description;
itemPrice = price;
itemQuantity = quantity;
}


ItemToPurchase::~ItemToPurchase()
{
}

void ItemToPurchase::SetName(string someString)
{
this->itemName = someString;
}

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

void ItemToPurchase::SetPrice(int somePrice)
{
this->itemPrice = somePrice;
}

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

void ItemToPurchase::SetQuantity(int someQuantity)
{
this->itemQuantity = someQuantity;
}

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

void ItemToPurchase::SetDescription(string description)
{
this->itemDescription = description;
}

string ItemToPurchase::GetDescription()
{
return itemDescription;
}

void ItemToPurchase::PrintItemCost()
{
cout << GetName() << " " << GetQuantity() << " @ $" << GetPrice() << " = $" << GetQuantity() * GetPrice();
}

void ItemToPurchase::PrintItemDescription()
{
cout << GetName() << ": " << GetDescription();
}
---------------------------------------------------------------------------------------------------
ItemToPurchase.h
-------------------------------------------------------------
#pragma once
#include <string>

using namespace std;

class ItemToPurchase
{
private:

string itemName;
int itemPrice;
int itemQuantity;
string itemDescription;

public:
ItemToPurchase(string name, string description, int price, int quantity);
ItemToPurchase();
~ItemToPurchase();

void SetName(string someString);
string GetName();
void SetPrice(int somePrice);
int GetPrice();
void SetQuantity(int someQuantity);
int GetQuantity();

void SetDescription(string description);
string GetDescription();
void PrintItemCost();
void PrintItemDescription();


};

Output Screenshot:-

Please give me a UPVOTE. Thank you ?


Related Solutions

This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1)...
This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class to contain a new attribute. (2 pts) item_description (string) - Set to "none" in default constructor Implement the following method for the ItemToPurchase class. print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter. Ex. of print_item_description() output: Bottled Water: Deer Park, 12 oz. (2) Build the ShoppingCart class with the following data attributes and related methods....
This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1)...
This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class to contain a new attribute. (2 pts) item_description (string) - Set to "none" in default constructor Implement the following method for the ItemToPurchase class. print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter. Ex. of print_item_description() output: Bottled Water: Deer Park, 12 oz. (2) Build the ShoppingCart class with the following data attributes and related methods....
IN C++ 7.22 LAB*: Program: Online shopping cart (Part 2) This program extends the earlier "Online...
IN C++ 7.22 LAB*: Program: Online shopping cart (Part 2) 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...
In python 3 please: This program extends the earlier "Online shopping cart" program. (Start working from...
In python 3 please: This program extends the earlier "Online shopping cart" program. (Start working from your Program 7). (1) Build the ShoppingCart class with the following data attributes and related methods. Note: Some can be method stubs (empty methods) initially, to be completed in later steps.(3 pt) ● Parameterized constructor which takes the customer name and date as parameters ● Attributes ○ customer_name (string) ○ current_date (string) ○ cart_items (list) ● Methods ○ add_item() ■ Adds an item to...
This week you will write a program that mimics an online shopping cart . You will...
This week you will write a program that mimics an online shopping cart . You will use all the programming techniques we have learned thus far this semester, including if statements, loops, lists and functions. It should include all of the following: The basics - Add items to a cart until the user says "done" and then print out a list of items in the cart and a total price. - Ensure the user types in numbers for quantities -...
Python This week you will write a program in Python that mimics an online shopping cart...
Python This week you will write a program in Python that mimics an online shopping cart . You will use all the programming techniques we have learned thus far this semester, including if statements, loops, lists and functions. It should include all of the following: The basics - Add items to a cart until the user says "done" and then print out a list of items in the cart and a total price. - Ensure the user types in numbers...
Python This week you will write a program in Pyhton that mimics an online shopping cart...
Python This week you will write a program in Pyhton that mimics an online shopping cart . You will use all the programming techniques we have learned thus far this semester, including if statements, loops, lists and functions. It should include all of the following: The basics - Add items to a cart until the user says "done" and then print out a list of items in the cart and a total price. - Ensure the user types in numbers...
9.25 LAB*: Program: Online shopping cart (Part 2) Note: Creating multiple Scanner objects for the same...
9.25 LAB*: Program: Online shopping cart (Part 2) Note: Creating multiple Scanner objects for the same input stream yields unexpected behavior. Thus, good practice is to use a single Scanner object for reading input from System.in. That Scanner object can be passed as an argument to any methods that read input. This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class per the following specifications: Private fields string itemDescription -...
Create a Python 3 program that acts as a grocery store shopping cart. 1. Create a...
Create a Python 3 program that acts as a grocery store shopping cart. 1. Create a class named GroceryItem. This class should contain: - an __init__ method that initializes the item’s name and price - a get_name method that returns the item’s name - a get_price method that returns the item’s price - a __str__ method that returns a string representation of that GroceryItem - an unimplemented method is_perishable Save this class in GroceryItem.py. 2. Create a subclass Perishable that...
would car insurance be covered if a shopping cart in the parking lot banged into your...
would car insurance be covered if a shopping cart in the parking lot banged into your car because of wind. Please explain ?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT