Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Demonstrate composition. Create a HardDrive class with the following attributes. brand : string sizeInTB : float Create a Computer class with the following attributes.

1. Demonstrate composition. Create a HardDrive class with the following attributes.

brand : string

sizeInTB : float

Create a Computer class with the following attributes.

brand : string

drive : HardDrive

2.

Write a Rectangle class that has the following member variables.

length

width

The class should have the following member functions.

Default constructor that sets length and width to 0.0

Constructor that accepts the length and width as arguments

setLength, a mutator function for the length variable

getLength, an accessor function for the length variable

setWidth, a mutator function for the width variable

getWidth, an accessor function for the width variable

calculateArea, returns area, which is calculated as area = length width

calculatePerimeter, returns perimeter, which is calculated as perimeter = 2 length + 2 width

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions