Java Programming Read the files attached and submit the following files:
Television.java, Your definition of the Television class.
TelevisionDemo.java
Read the files attached and submit the following files:
- Television.java, Your definition of the Television class.
- TelevisionDemo.java, Your final version of the file.
- Always include a comment line containing your full name in all Java source code files you create or modify
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 named bigscreen.
Television bigScreen = new Television(“Samsung”, 58);
// 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 by five.
for (int i = 0; i < 5; i++)
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
//
// ADD LINES FOR TASK #5 HERE:
// Task #5 Creating another instance of a Television object.
//
// Declare and instantiate a television object.
// Declare another Television object named office.
// Instantiate the office television to be a Sony 43-inch television.
// Use a call to the power method to turn the power on.
// Turn the power on.
// Use calls to the accessor methods to print what television
// was turned on.
// Display the state of the television.
// Use calls to the mutator methods to change the channel to
// the user’s preference and decrease the volume by two.
// Prompt the user for input and store into station.
// Change the channel on the television.
// Decrease the volume of the television.
// Display the current channel and volume
// of the television.
}
}