Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ Create a Grocery list dynamically allocated object. also store pointer in to a standard vector //GroceryItem.hpp #pragma once // include guard #include #include class

c++ Create a Grocery list dynamically allocated object. also store pointer in to a standard vector

//GroceryItem.hpp

#pragma once // include guard

#include #include

class GroceryItem { // Insertion and Extraction Operators friend std::ostream & operator<<( std::ostream & stream, const GroceryItem & groceryItem ); friend std::istream & operator>>( std::istream & stream, GroceryItem & groceryItem );

// Relational Operators friend bool operator==( const GroceryItem & lhs, const GroceryItem & rhs ); friend bool operator< ( const GroceryItem & lhs, const GroceryItem & rhs );

public: // Constructors GroceryItem() = default; GroceryItem( const std::string & productName, const std::string & brandName = {}, const std::string & upcCode = {}, double price = 0.0 );

// Queries std::string upcCode () const; std::string brandName () const; std::string productName () const; double price () const;

// Mutators void upcCode ( const std::string & upcCode ); void brandName ( const std::string & brandName ); void productName ( const std::string & productName ); void price ( double price );

private: std::string _upcCode; std::string _brandName; std::string _productName; double _price = 0.0; };

// Relational Operators bool operator==( const GroceryItem & lhs, const GroceryItem & rhs ); bool operator!=( const GroceryItem & lhs, const GroceryItem & rhs ); bool operator< ( const GroceryItem & lhs, const GroceryItem & rhs ); bool operator<=( const GroceryItem & lhs, const GroceryItem & rhs ); bool operator> ( const GroceryItem & lhs, const GroceryItem & rhs ); bool operator>=( const GroceryItem & lhs, const GroceryItem & rhs );

output----

Welcome to Kroger. Place grocery items into your shopping basket by entering each product's information. enclose string entries in quotes, separate fields with comas CTL-Z (Windows) or CTL-D (Linux) to quit

Enter UPC, Product Brand, Product Name, and Price Item added to shopping basket: "00072250018548", "Nature's Own", "Nature's Own Butter Buns Hotdog - 8 Ct", 10.79

Enter UPC, Product Brand, Product Name, and Price Item added to shopping basket: "00028000517205", "Nestle", "Nestle Media Crema Table Cream", 17.97

Enter UPC, Product Brand, Product Name, and Price Item added to shopping basket: "00034000020706", "York", "York Peppermint Patties Dark Chocolate Covered Snack Size", 12.64

Enter UPC, Product Brand, Product Name, and Price Item added to shopping basket: "00038000570742", "Kellogg's", "Kellogg's Cereal Krave Chocolate", 18.66

Enter UPC, Product Brand, Product Name, and Price Item added to shopping basket: "00014100072331", "Pepperidge Farm", "Pepperidge Farm Classic Cookie Favorites", 14.43

Enter UPC, Product Brand, Product Name, and Price

Here is an itemized list of the items in your shopping basket: "00014100072331", "Pepperidge Farm", "Pepperidge Farm Classic Cookie Favorites", 14.43 "00038000570742", "Kellogg's", "Kellogg's Cereal Krave Chocolate", 18.66 "00034000020706", "York", "York Peppermint Patties Dark Chocolate Covered Snack Size", 12.64 "00028000517205", "Nestle", "Nestle Media Crema Table Cream", 17.97 "00072250018548", "Nature's Own", "Nature's Own Butter Buns Hotdog - 8 Ct", 10.79 `

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_2

Step: 3

blur-text-image_3

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

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions