Answer to Question #303851 in Java | JSP | JSF for Angel

Question #303851

Create another class called Television. Television is an Appliance. It only has the following additional private attributes:



type (whether Smart or Non-Smart)


volume (0 - 100)


channel (1 - 100)


It should have the following methods:



getters


void volumeUp() - increases the volume by 1 (possible only when TV is ON)


void volumeDown() - decreases the volume by 1 (possible only when TV is ON)


void channelUp() - increases the channel by 1 (possible only when TV is ON)


void channelDown() - decreases the channel by 1 (possible only when TV is ON)


String toString() - overriding Appliance's. It should include type, volume, and channel in this format ("Brand: xxxx, Cost: PhP xxxx.xx, Power: xx, Type: xxxx, Volume: xx, Channel: xx").




A lone constructor is to be implemented with a type, brand, and cost as an argument. It sets the volume to 0 and channel to 1. And it prints "Television Constructor" as well

1
Expert's answer
2022-02-28T16:21:15-0500
public class Television extends Appilance {
    private String type;
    private int volume;
    private int channel;

    public Television(String type, String brand, double cost) {
        super(brand, cost);
        this.type = type;
        volume = 0;
        channel = 1;
        System.out.println("Television Constructor");
    }

    public String getType() {
        return type;
    }

    public int getVolume() {
        return volume;
    }

    public int getChannel() {
        return channel;
    }

    public void volumeUp() {
        if (isPower()) {
            volume++;
        }
    }

    public void volumeDown() {
        if (isPower()) {
            volume--;
        }
    }

    public void channelUp() {
        if (isPower()) {
            channel++;
        }
    }

    public void channelDown() {
        if (isPower()) {
            channel--;
        }
    }

    @Override
    public String toString() {
        return super.toString() + ", Type: " + type + ", Volume: " + volume + ", Channel: " + channel;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Angel
01.03.22, 01:35

Thank you for Answering my question

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS