QuestionQuestion

Programming Project: TVRemote
Overview: The purpose of this project is to give you experience in writing a class that implements an interface. You will create a class named TVRemote which will encapsulate a simple television remote control.

A universal remote control is a good example to use in understanding the idea behind a Java interface. With a universal remote you use the same buttons to control similar functions on different audio-visual devices. Thus you have a “standardized” way to change the channel by pressing the “Channel Up” button whether the remote is set to control your TV or your VCR – you still press the same button. That’s the idea behind interfaces, they provide a set of methods to be used by classes to carry out what to the user are “the same” operations. This project makes use of an interface named RemoteControl which you will implement in your TVRemote class but the same interface could be implemented by a VCRRemote class or a DVDRemote class. The benefit is that only one set of method API’s has to be learned by users of the classes. TVRemote, VCRRemote, and DVDRemote objects all do the same thing the same way as far as the user is concerned. For example, need to turn up the volume on your TV/VCR/DVD player object? Simply call the volumeUp method.

The interface RemoteControl and class TVRemoteFrame are provided as instructor attachments. Your TVRemote class will implement RemoteControl and you can use TVRemoteFrame to test your TVRemote class.
Specifications:    Code a public class named TVRemote that implements RemoteControl as described below. As always, you are not authorized to add, modify, or remove members of this class.

Data members:
A private boolean variable named power.
A private boolean variable named muted.
A private int constant named MIN_CHANNEL initialized to 2.
A private int constant named MAX_CHANNEL initialized to 10.
A private int variable named channel.
A private int constant named MIN_VOLUME initialized to 0.
A private int constant named MAX_VOLUME initialized to 10.
A private int variable named volume.
Constructor:
A public default constructor that initializes power to false, muted to false, channel to MIN_CHANNEL, and volume to MIN_VOLUME.

Methods:
getPower: a public accessor method that returns power.
getMuted: a public accessor method that returns muted.
getChannel: a public accessor method that returns channel.
getVolume: a public accessor method that returns volume.
powerOnOff: a public void method that takes no parameters. First, if the power is on and the sound is muted the mute method is called. Second, power is set to its negated value.
mute: a public void method that takes no parameters. If the power is on then muted is set to its negated value.
channelUp: a public void method that takes no parameters. If the power is on then channel is increased by one unless it’s at the maximum in which case channel is set to the minimum channel.
channelDown: a public void method that takes no parameters. If the power is on then channel is decreased by one unless it’s at the minimum in which case channel is set to the maximum channel.
volumeUp: a public void method that takes no parameters. First, if the power is on and the sound is muted the mute method is called. Second, if the power is on then volume is increased by one unless it’s at the maximum.
volumeDown: a public void method that takes no parameters. First, if the power is on and the sound is muted the mute method is called. Second, if the power is on then volume is decreased by one unless it’s at the minimum.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import javax.swing.event.*;
import javax.swing.border.*;

public class TVRemoteFrame extends JFrame
{
public TVRemoteFrame()
{
setTitle("TV Remote");
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension d = tk.getScreenSize();
int height = 150;
int width = 375;
setBounds((d.width - width) / 2, (d.height - height) / 2, width, height);
setResizable(false);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
Container contentPane = getContentPane();
JPanel panel = new TVRemotePanel();
contentPane.add(panel);
}

public static void main(String[] args)
{
JFrame frame = new TVRemoteFrame();
frame.setVisible(true);
}
}

class TVRemotePanel extends JPanel implements ActionListener
{
private RemoteControl remoteControl = new TVRemote();
private TVRemote remote = (TVRemote)remoteControl;

private JLabel channelLabel, volumeLabel, powerLabel;
private JButton powerButton, muteButton, channelUpButton, channelDownButton, volumeUpButton, volumeDownButton;

public TVRemotePanel()
{
setLayout(new GridLayout(3, 3));

setBorder(new TitledBorder(new EtchedBorder(), "PlasmaTron"));...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

50% discount

Hours
Minutes
Seconds
$30.00 $15.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats