Nothing Special   »   [go: up one dir, main page]

CPA: Programming Essentials in C++: Lab 6.5.1 Composition: Part 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

CPA: Programming

Essentials in C++ C++ INSTITUTE - PROGRAM YOUR FUTURE

Lab 6.5.1 Composition: part 2


Objectives
Familiarize the student with:

modelling real-world entities in C++;


the composition of objects from objects of other classes.

Scenario
Below is a recipe for constructing a primitive car. All class names start with a capital letter. Compose a Car from some objects, you
should use: one Engine, four Wheels, one Chassis, ten Lights, and one Body. Feel free to define the attributes of these classes. Every
class (including Car) must have a print method. In the print method of Car, you just need to call the print method from all the objects.
Create one car and call a print method.

Example input
Just print values for one car.

Example output
Engine: 1.0
Wheel: 16inches
Wheel: 16inches
Wheel: 16inches
Wheel: 16inches
Chassis: Normal
Light: Type 1
Light: Type 1
Light: Type 2
Light: Type 2
Light: Type 3
Light: Type 3
Light: Type 4
Light: Type 4
Light: Type 5
Light: Type 5
Body: Black

© 2017 C++ Institute. All rights reserved. Last updated: March 07, 2017 | www.cppinstitute.org Page 1 of 1

You might also like