Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 3 0 points ) Transform the following UML diagram to a TV class. TV channel: int volumeLevel: int on: bool + TV ( )

(30 points) Transform the following UML diagram to a TV class.
TV
channel: int
volumeLevel: int
on: bool
+TV()
+turnOn(): void
+turnOff(): void
+setChannel(newChannel: int): void
+setVolume(newVolumeLeve: int): void
+channelUp(): void
+channelDown(): void
+volumeUp(): void
+volumeDown(): void
The current channel (1 to 120) of this TV.
The current volume level (1 to 7) of this TV.
Indicates whether this TV is on/off.
Constructs a default TV object.
Turns on this TV.
Turns off this TV.
Sets a new channel for this TV.
Sets a new volume level for this TV.
Increases the channel number by 1.
Decreases the channel number by 1.
Increases the volume level by 1.
Decreases the volume level by 1.
This class should include three public data members, int channel, int volumeLevel, and bool on
and nine public functions. The function TV() is a constructor, turnOn() turns the TV on,
turnOff() turns the TV off, setChannel(int newChannel), sets a new channel for this TV,
setVolume(int newVolumeLevel), sets a new volume level for this TV, channelUp() increases
the channel number by one, channelDown() decreases the channel number by one,
volumeUp() increases the volume level by one, channelDown() decreases the volume level by
one.
Do the following:
1. Write the TV class definition in a file named Tv.h
2. Write the class implementation in Tv.cpp
3. Your class should include a test driver function main(). This main() should declare two TV
objects. One invokes channel functions. The other invokes volume levels. Display channel
and volumeLevels for each TV. Make sure your program is working correctly.
2
1.1 Tv.h
3
1.2 Tv.cpp
4
1.3 main
5
1.4 Test run

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_2

Step: 3

blur-text-image_3

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

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions

Question

What is a maturity model?

Answered: 1 week ago

Question

I wasnt sure how to talk about this situation. It was too personal.

Answered: 1 week ago