0

I have tried to fix the television method but I keep getting the same error: connot find symbol constructor Television(java.lang.String,int). I'd appreciate if someone would tell me why am I getting this error message. here is my code:

import java.util.Scanner;
public class Television
{
    private String manufacturer;       //the brand name
    private int SCREEN_SIZE;           //the size of the television screen.
    private boolean powerOn;           //the value true if the power is on
    private int channel;               //the value of the station that the television is showing.
    private int volume;                //a number value representing the loudness

    Scanner keyboard = new Scanner(System.in);
    /*
     *Constructor to assign the values to manufacturer and SCREEN_SIZE
     *@param the manufacturer value
     *@param the SCREEN_SIZE value
     */
    public Television(String sony, int size, int chan)
    {
        manufacturer = sony;
        SCREEN_SIZE = size;
        channel = chan;

        powerOn = false;
        channel = 2;
        volume = 20;
    }
    public int getChannel()
    {
        return channel;
    }
    public int getVolume()
    {
        return volume;
    }
    public String getManufacturer()
    {
        return manufacturer;
    }
    public int getScreenSize()
    {
        return SCREEN_SIZE;
    }
    public void setChannel(int channel)
    {
        channel = keyboard.nextInt();
    }
    public void power()
    {
        if (true)
        {
            powerOn = !powerOn;
        }
        else
        {
            powerOn = powerOn;
        }
    }
    public void increaseVolume()
    {
        volume = volume + 1;
    }
    public void decreaseVolume()
    {
        volume = volume - 1;
    }
public static void main(String[] args)
{
    //create a Scanner object to read from the keyboard
    Scanner keyboard = new Scanner (System.in);
    //declare variables
    int station; //the user’s channel choice


    //declare and instantiate a television object
    Television bigScreen = new Television("Toshiba", 55);



    //turn the power on
    bigScreen.power();
    //display the state of the television
    System.out.println("A " + bigScreen.getScreenSize() +
    bigScreen.getManufacturer() + " has been turned on.");
    //prompt the user for input and store into station
    System.out.print("What channel do you want? ");
    station = keyboard.nextInt();
    //change the channel on the television
    bigScreen.setChannel(station);
    //increase the volume of the television
    bigScreen.increaseVolume();
    //display the the current channel and volume of the television
    System.out.println("Channel: " + bigScreen.getChannel() +
    " Volume: " + bigScreen.getVolume());
    System.out.println("Too loud!! I am lowering the volume.");
    //decrease the volume of the television
    bigScreen.decreaseVolume();
    bigScreen.decreaseVolume();
    bigScreen.decreaseVolume();
    bigScreen.decreaseVolume();
    bigScreen.decreaseVolume();
    bigScreen.decreaseVolume();
    //display the current channel and volume of the television
    System.out.println("Channel: " + bigScreen.getChannel() +
    " Volume: " + bigScreen.getVolume());
    System.out.println(); //for a blank line
    //HERE IS WHERE YOU DO TASK #5
}
}

2 Answers 2

4

Your Television constructor accepts three arguments, a string and two ints and you are just passing two arguments.

Television bigScreen = new Television("Toshiba", 55);

should be

Television bigScreen = new Television("Toshiba", 55, there should be another int argument here);

as i can see in from your code, you should be passing an int (channel) to your constructor as the third argument.

Sign up to request clarification or add additional context in comments.

Comments

2

The constructor defined to receive 3 parameter while you pass it just two

public Television(String sony, int size, int chan);

Television bigScreen = new Television("Toshiba", 55);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.