Question
//GroceryItem.hpp #pragma once // include guard #include #include class GroceryItem { // Insertion and Extraction Operators friend std::ostream & operator>( std::istream & stream, GroceryItem &
//GroceryItem.hpp
#pragma once // include guard
#include #include
class GroceryItem { // Insertion and Extraction Operators friend std::ostream & operator>( std::istream & stream, GroceryItem & groceryItem );
// Relational Operators friend bool operator==( const GroceryItem & lhs, const GroceryItem & rhs ); friend bool operator
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 );
Learning Goals: Become familiar with creating compiling, running and submitting promin e nts Demonstrate mastery of basic C sills, including alocating and releasing dynamic memory reading from standard input and writing to standard output working with standard vectors overloading Insertion and extraction operators Demonstrate the former s om Refresh your memory and mor e our point of departure Depending on your background and how long ago you actively practiced programming in Ceme of this may be review and some my w ou Description: In this assignment, you will play both the role of dass designer and the role of a consumer. As class designer you will implement the provided class interface, and then the c o me you will starte objects of this des to solve a simple problem. The class self has a few private attributes, and a multiparameter C ructor. Objects of the dess have the fundamental capability to insert, extract, and compare themselves. The problem being solved is simply to read several objects storing the dynamically and after you've read them all print them in reverse order Specifically, you are to implement 1. A class named Groceryltem. You will reuse this dass in future homework assignments, so effort you apply getting it right now will greatly benefit you later. a. Attributes 1. Product Name-the name of the product e n Tomato Ketchup.2 Ct, Boston Market Spaghetti with Meatbals) Brand Name-the product manufacture's brand name Heine, Boston Market) H. UPC-a 14-digit Universal Product Code niquely dentifying the items 51600080015 05017402006207). Case this as a sing type, not an integral type iv. Price-the cost of the item in US Dollars Ex 2.29, 1.19). Code this as type double b. Construction I. Allow grocery items to be constructed with zero, one, two, three or four arguments! The first argument must be the product name, the second the brand name the third the UPC, and the fourth the price ii. Initialize each attribute with member initialization and in the constructor's initialization list. Do not set the attribute's value in the body of the constructor c Operations Set and retrieve each of the attributes. Name your overloaded functions Code brandName, product Name, and price. For example: upeCode [ const stating & upecadel//mutate std::strin upecade cont HEY il. Overload the insertion and extraction operators. For example, main may read from standard input and write to standard output a Grocerylte obiecte this Crocery Item recesyaten: std::cin >> Ecosylten / L ion (ading etdttcoutStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started