Question: Task 1 . ( Using C + + ) Use the composition technique to write a class declaration and main ( ) for the following

Task 1.(Using C++)
Use the composition technique to write a class declaration and main() for the following scenarios:
Create a class called Book. The Book class has the following attributes:
bookld (int)
title (string)
author (string)
price (double)
bookCount (static int =1001)
Methods:
bookId is automatically assigned by the system, starting from 1001 and increasing by 1. The title, author and price attributes are accepted from main() as parameters when the object is created. (Constructor).
showBook() function displays bookId, title, author, and price on the screen.
Create a class called Order. The Order class has the following attributes:
orderId (int)
quantity (int)
book (Book)
Methods:
All order data members accept data from main() as parameters when the object is created. (Constructor)
Write a calculateTotal() function that calculates and returns the total price of the order according to the formula:
totalPrice = quantity ** book.price
(How can you access the private member of another class?)
showOrder() function displays order ID, book information, quantity, and total price to the screen.
Create a class called Customer. The Customer class has the following attributes:
customerld (int)
customerName (string)
phoneNo (string)
placedOrder (Order)
Methods:
All customer data members accept data from main 0 as parameters when the object is created. (Constructor)
showCustomer() function displays customer ID, customer name, phone number, placed order information to the screen.
Main(
Write a program that calculates and prints all information of a customer to the screen with the following format:
 Task 1.(Using C++) Use the composition technique to write a class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!