public class TVRemote {
//initialize variables
private int channel, vol;
public TVRemote(){this(0,0);}
public int getChannel(){return channel;}
public void setChannel(int a){channel = a;}
public TVRemote(int a, int b){setChannel(a); setVolume(b);}
public int getVolume(){return vol;}
public void setVolume(int b){vol = b;}
public void channelUp(){
channel++; }
public void channelDown(){
channel--; }
public void changeChannel(int x){
channel = x;
}
public void changeVolume(int b){vol = b;}
public void volumeUp(){
vol++; }
public void volumeDown(){
vol--; }
//prints out the final report of the program
public void display() {
System.out.println("Channel = "+channel);
System.out.println("Volume = "+vol);
}}
public class TVRemoteClient {
public static void main(String args[])
{
TVRemote t = new TVRemote(22 ,10);
t.channelUp();/*increase the channel*/
t.display(); /*display current status of channel and volume*/
t.changeChannel(1); /*directly set channel*/
t.display(); /*display current status of channel and volume*/
t.channelDown();/*go down to next channel*/
t.volumeUp(); /*increase volume by one*/
t.display(); /*display current status of channel and volume*/
public class DVDRemote extends TVRemote{
private String mode;
private int status;
public DVDRemote(){this(0,null);}
public DVDRemote(int c, String d){
super(0,0);
mode = null;
status = 0;
}
public String getMode(){return mode;}
public void setMode(String a){mode = a;}
public int getStatus(){return status;}
public void setStatus(int b){status = b;}
public void changeStatus(int x){
if(x>-1&&x<2)
status = x; }
public void statusEject(){
status=0; }
public void changeMode(String x){
mode = x;
}
public void StatusDVD(){
status = 1; }
public boolean equals(DVDRemote a){return true;}
//prints out the final report of the program, their percentage, and if they need help with their chosen subject
public void display() {
System.out.println("Channel = "+getChannel());
System.out.println("Volume = "+getVolume());
System.out.println("Status = "+mode);
if(status==0){
System.out.println("There is no DVD in the machine.");}
if(status==1){
System.out.println("There is a DVD in the machine.");}
}}
public class DVDRemoteClient{
public static void main(String[]args){
DVDRemote v = new DVDRemote(1, "Play");
v.setChannel(100);
v.setVolume(10);
v.StatusDVD();
v.setMode("stop");
v.display();
v.setMode("Fast forward");
v.display();
}
}
Here's what I have so far. The assignment (final project) is:
Create a class TVRemote. This class will simulate a TV remote control.
Data members:
* channel
*volume level
*any other you wish to addMember methods:
* overloaded constructors (no data, channel data only, volume and channel data)
* get and set methods for all data members
* channelUp and channelDown methods (can't exceed or go below your channel limit and will go from last channel to first channel)
* volumeUp and volumeDown methods (can't exceed or go below your volume level)Requirements:
In a client, instantiate a TVRemote object and demonstrate its capabilities (change volume, up and down; change channels, up and down, and direct input).Example of client code:
TVRemote t = new TVRemote(22,10); /*instantiate object*/
t.channelUp();/*increase the channel*/
t.display(); /*display current status of channel and volume*/
t.changeChannel(1); /*directly set channel*/
t.display(); /*display current status of channel and volume*/
t.channelDown();/*go down to next channel*/
t.volumeUp(); /*increase volume by one*/
t.display(); /*display current status of channel and volume*/Part B
Using the class TVRemote from Part A above, create a class DVDRemote class that inherits from TVRemote. In addition to the data members and member methods it inherits, it will have the following methods:Data members:
your choice
Member methods:
insertDVD()
ejectDVD()
setMode()
getMode()The user should be able to play, stop, fast forward, and rewind a DVD in the setMode method. The getMode method should tell the user what mode the DVD is in or that a DVD is not in the machine.
Requirements:
In a client, instantiate a DVDRemote object and demonstrate its capabilities (including its ability to operate the TV).
Example of client code:DVDRemote v = new DVDRemote(“play”);
v.setMode(“stop”);
v.display();
v.setMode(“fast forward”);
My code runs, but I'm not sure I have everything asked for in the project. I think it's fine, but would really appreciate the help of the experts here. Also, is there anything I could/should do differently, or anything I may have missed.
Thanks