Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework 1 (Classes, Inheritance) Instructions Every assignment needs to provide two main artifacts a complete working program, along with its full source code, and your

Homework 1 (Classes, Inheritance) Instructions Every assignment needs to provide two main artifacts a complete working program, along with its full source code, and your solution documentation. The documentation should be in a single text file (e.g. doc), placed inside your Solution folder. For this assignment, the documentation will make 10% of the grade, and code will be 90%. In the documentation you need to describe the data types you chose for implementing the classes member variables, the return types and parameters for the public functions (including the constructors), and the reasons for choosing them. The software fraction of the homework will be graded according to the following rules: existence of compile-time errors not more than 20 % existence of run-time errors not more than 50 % existence of logical-errors not more than 70 % correct program not less than 70 % The last 30 points for the software part will be given for program comments, efficiency, class hierarchies, textual representation, structure, layout, etc. NOTE: If the program is not correct, credits for these properties will not be given! NOTE: An incomplete implementation of the required functionality is consider a logical error. Deliverables A zipped top-level folder of the Visual Studio solution, containing all of the code, plus the document describing the program. NOTE: You may be asked to demonstrate your solution in person. Deadline The complete homework (code and documentation) must be uploaded on Canvas no later than Sunday, 12th February, 2023, 23:59. NOTE: Late work will be accepted but penalized. 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

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions