Question
Implement a program in C++ to represent a Market Store. For this first assignment, you need to develop the following classes: 1. Category Data Slots:
Implement a program in C++ to represent a Market Store. For this first assignment, you need to develop the following classes: 1. Category Data Slots: TextKey (string) e.g. ABCD-EFGH-1234 Name (string) e.g. Electronics Description (long string) Parent (Category) a parent category, can be NULL
Methods: Constructor(s) Axioms: TextKey must be unique across other categories text keys 2. Product Data Slots: TextKey (string) Name (string) e.g. Coca-Cola Description (long string) Category (Category) cannot be empty Price (double) e.g. 185.99 Discount (double) e.g. 30 DiscountType (enum) amount or percentage Quantity (number) Methods: Constructor(s) double GetEffectivePrice { If DiscountType is amount: Return Price Discount Else: Return Price Price * Discount / 100 } double GetTotalPrice { Return Quantity * GetEffectivePrice() } Axioms: Price, Discount and Quantity cannot be negative GetEffectivePrice() and GetTotalPrice() should not return a negative amount 3. Service (inherits Product) Own Data Slots: Duration (double) e.g. 1.5 (service execution duration in hours) Rate (double) e.g. 8.50 RateDiscount (double) e.g. 30 RateDiscountType amount or percentage Methods: Constructor(s) double GetEffectiveRate { If RateDiscountType is amount: Return Rate RateDiscount Else: Return Rate Rate * RateDiscount / 100 } double GetTotalPrice { Product::GetTotalPrice() + GetEffectiveRate() * Duration }
Axioms: Duration, Rate and RateDiscount cannot be negative GetEffectiveRate() and GetTotalPrice() should not return negative amount
Driver Program: 1. Define three vectors for storing the data for the Market Store: (1) Categories pointers of object instances of class Category available for your store (2) Products pointers of instances of Product (3) Services pointers of instances of Service 2. Add code to implement the following functionality in the rest of the driver program: (1) Add at least three new categories to the Category collection (2) Add at least three products to the Product list, which have a correct Category from the list of available and instantiated categories in the previous step (3) Add at least three services to the Services list, having a valid Category (4) Use two loops to show the Name and Total Price of each product and service in the store
Step 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