Question: Implement a program in C++ to represent a Company that sells its production and services to clients. The company has different departments which produce different
Implement a program in C++ to represent a Company that sells its production and services to clients. The company has different departments which produce different products. Products are sold for a certain price and can have a discount. The company also offers Services to its clients e.g. custom development.
For this first assignment, you need to develop the following classes:
1. Department
Data Slots:
- ID (string) e.g. ABCD-EFGH-1234
- Name (string) e.g. Electronics
- Room (number) e.g. 260
- PhoneNumber (string) e.g. 0888 123456
- Parent (Department) a parent department, can be NULL
Methods:
- Constructor(s)
Axioms:
- ID must be unique across other departments IDs
2. Product
Data Slots:
- Name (string) e.g. PC Tools
- Description (string)
- Category (string) the product category e.g. Games
- Department (Department) department which developed the product; cannot be empty
- Price (real number) e.g. 185.99
- Discount (real number) e.g. 30
- DiscountType (enum) amount or percentage
Methods:
- Constructor(s)
- double GetTotalPrice {
- If DiscountType is amount:
- Return Price Discount
- Else:
- Return Price Price * Discount / 100
- }
Axioms:
- Price and Discount cannot be negative
- GetTotalPrice() should not return a negative amount
3. Service (inherits Product)
Own Data Slots:
- Duration (real number) e.g. 1.5 (service execution duration in hours)
- Rate (real number) e.g. 8.50
- RateDiscount (real number) e.g. 30
- RateDiscountType amount or percentage
Methods:
- Constructor(s)
- double GetTotalPrice {
- If RateDiscountType is amount:
- Return Rate RateDiscount
- Else:
- Return Rate Rate * RateDiscount / 100
- }
Axioms:
- Duration, Rate and RateDiscount cannot be negative
- GetTotalPrice() should not return negative amount
Driver Program:
- Define three vectors for storing the data for the company:
- Departments pointers of object instances of class Department available for your store
- Products pointers of instances of Product
- Services pointers of instances of Service
- Add code to implement the following functionality in the rest of the driver program:
- Add at least three new departments to the Departments collection
- Add at least three products to the Product list, which have a correct Department from the list of available and instantiated departments in the previous step
- Add at least three services to the Services list, having a valid Department
- 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
Get step-by-step solutions from verified subject matter experts
