-
Notifications
You must be signed in to change notification settings - Fork 0
/
TelevisionDemo.java
82 lines (51 loc) · 2.37 KB
/
TelevisionDemo.java
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//Captain-Price-TF-141
import java.util.Scanner; // Needed for the Scanner class
//This class demonstrates the Television class.
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! Lowering the volume.");
// Decrease the volume of the television
bigScreen.decreaseVolume();
bigScreen.decreaseVolume();
bigScreen.decreaseVolume();
bigScreen.decreaseVolume();
bigScreen.decreaseVolume();
bigScreen.decreaseVolume();
// Display the 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 portable = new Television("Sharp", 19);
portable.power();
System.out.println("A " + portable.getScreenSize() + " inch " + portable.getManufacturer() + " has been turned on.");
System.out.print("What channel do you want? ");
station = keyboard.nextInt();
portable.setChannel(station);
portable.decreaseVolume();
portable.decreaseVolume();
System.out.println("Channel: " + portable.getChannel() + " Volume: " + portable.getVolume());
}
}