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.
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.
A public default constructor that initializes power to false, muted to false, channel to MIN_CHANNEL, and volume to MIN_VOLUME.
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.
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.*;
public class TVRemoteFrame extends JFrame
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);
public void windowClosing(WindowEvent e)
Container contentPane = getContentPane();
JPanel panel = new TVRemotePanel();
public static void main(String args)
JFrame frame = new TVRemoteFrame();
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;
setLayout(new GridLayout(3, 3));
setBorder(new TitledBorder(new EtchedBorder(), "PlasmaTron"));...
By purchasing this solution you'll be able to access the following files: