This is a Java question. For it, we will assume the following: Class TelevisionC
ID: 3738204 • Letter: T
Question
This is a Java question. For it, we will assume the following: Class TelevisionChannel has three fields: name, a String; number, an integer; and Boolean, which represents whether the channel is a cable channel. Code a constructor for that class that takes three parameters. This is a Java question. For it, we will assume the following: Class TelevisionChannel has three fields: name, a String; number, an integer; and Boolean, which represents whether the channel is a cable channel. Code a constructor for that class that takes three parameters.Explanation / Answer
public class TelevisionChannel
{
String name;
int number;
boolean cable;
// constructor
TelevisionChannel()
{
this.name = "";
this.number = 0;
this.cable = true;
}
// constructor
TelevisionChannel(String name, int number, boolean cable)
{
this.name = name;
this.number = number;
this.cable = cable;
}
// getter methods
public String getName()
{
return this.name;
}
public int getNumber()
{
return this.number;
}
public boolean isCable()
{
return this.cable;
}
// setter methods
public void setName(String name)
{
this.name = name;
}
public void setNumber(int number)
{
this.number = number;
}
public void setCable(boolean cable)
{
this.cable = cable;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.