Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:
image text in transcribed

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

Students also viewed these Databases questions