Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 4 . 1 : Write a TV class ( without main method ) and declare its instance variables. The Default channel is 1 ,

Question 4.1: Write a TV class (without main method) and declare its instance variables. The Default channel is 1, the default volume level is 1 and the TV is off.
1. The turnOn method turns on this TV.
2. The turnOff method turns off this TV.
3. The setChannel method sets the new channel if the TV is on and the new
channel is between 1 and 120.
4. The setVolume method sets the new volume if the TV is on and the new volume
is between 1 and 7.
5. The channelUp method increases the channel number by 1 if the TV is on and
the channel is less than 120.
6. The channelDown method decreases the channel number by 1 if the TV is on
and the channel is greater than 1.
7. The volumeUp method increases the volume number by 1 if the TV is on and
the channel is less than 7.
8. The volumeDown method decreases the volume number by 1 if the TV is on
and the volume is greater than 1.
9. In the main class TestTV:
Run :
Question 4.2: Modify the code in order to initialize the first tv by the same values (channel =30 and volumeLevel =3 when creating the tv1).
a. create an object tv1 b. turn on the tv1
c. set the channel to 30 d. set volume to 3
e. create an object tv2
f. turn on the tv2
g. increase the channel of the tv2
h. increase the volume of the tv2
i. Show the channel and the volume
o

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 Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions