forked from Denisolt/CSCI-160
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTelevisionDemo.java
More file actions
67 lines (57 loc) · 2.3 KB
/
TelevisionDemo.java
File metadata and controls
67 lines (57 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/** This class demonstrates the Television class*/
import java.util.Scanner;
public class TelevisionDemo
{
public static void main(String[] args)
{
//create a Scanner object to read from the keyboard
Scanner keyboard = new Scanner (System.in);
//declare variables
int station; //the user's channel choice
//declare and instantiate a television object
Television bigScreen = new Television("Toshiba", 55);
//turn the power on
bigScreen.power();
//display the state of the television
System.out.println("A " + bigScreen.getScreenSize() + " inch " +
bigScreen.getManufacturer() + " has been turned on.");
//prompt the user for input and store into station
System.out.print("What channel do you want? ");
station = keyboard.nextInt();
//change the channel on the television
bigScreen.setChannel(station);
//increase the volume of the television
bigScreen.increaseVolume();
//display the the current channel and volume of the television
System.out.println("Channel: " + bigScreen.getChannel() +
" Volume: " + bigScreen.getVolume());
System.out.println("Too loud!! I am lowering the volume.");
//decrease the volume of the television
bigScreen.decreaseVolume();
bigScreen.decreaseVolume();
bigScreen.decreaseVolume();
bigScreen.decreaseVolume();
bigScreen.decreaseVolume();
bigScreen.decreaseVolume();
//display the current channel and volume of the television
System.out.println("Channel: " + bigScreen.getChannel() +
" Volume: " + bigScreen.getVolume());
System.out.println(); //for a blank line
//HERE IS WHERE YOU DO TASK #5
Television portableScreen = new Television("Sharp", 19);
portableScreen.power();
System.out.println("A " + portableScreen.getScreenSize() + " inch " +
portableScreen.getManufacturer() + " has been turned on.");
//prompt the user for input and store into station
System.out.print("What channel do you want? ");
station = keyboard.nextInt();
portableScreen.setChannel(station);
//display the the current channel and volume of the television
portableScreen.decreaseVolume();
portableScreen.decreaseVolume();
//display the current channel and volume of the television
System.out.println("Channel: " + portableScreen.getChannel() +
" Volume: " + portableScreen.getVolume());
System.out.println();
}
}