Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task Description Implement a program in C++ to represent a Market Store. For this first assignment, you need to develop the following classes: 1. Category

Task Description 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

COS 2021 Fundamental Data Structures Spring 2023 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 }

COS 2021 Fundamental Data Structures Spring 2023 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 NOTE: The purpose of the driver program is to test the classes you have implemented. There is no need to create any additional functionality such as user menus, reading user input, or reading information from files. All of the driver program requirements can be implemented by adding statements and static data in the main() function of your program.

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

Microsoft SQL Server 2012 Unleashed

Authors: Ray Rankins, Paul Bertucci

1st Edition

0133408507, 9780133408508

Students also viewed these Databases questions

Question

Explain the causes of indiscipline.

Answered: 1 week ago