This is a Java question. For it, we will assume the following: Class TelevisionC
ID: 3738205 • 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 the three accessors for that class. 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 the three accessors for that class.Explanation / Answer
TelevisionChannel.java
public class TelevisionChannel {
private String name;
private int number;
private boolean cable;
public TelevisionChannel() {
name = "";
number = 0;
cable = false;
}
public TelevisionChannel(String name, int number, boolean cable) {
this.name = name;
this.number = number;
this.cable = cable;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNumber() {
return number;
}
public void setNumber(int number) {
this.number = number;
}
public boolean isCable() {
return cable;
}
public void setCable(boolean cable) {
this.cable = cable;
}
public int business() {
int count = 0;
while(number > 0) {
count++;
number/=10;
}
return count;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.