-
Constructor help
i have create a constructor program and I ma having some trouble. im at step #2 on this project found at this webpage.
www.shsu.edu/~csc_tjm/cs146/Lab2.doc
if someone could help me figure out how to make the constructor for this program it would be greatly appreciated. Here is the code of the file that goes with the one I have to create
public class TelevisionDemo
{
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 instatiate 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.println("What channel do you want? ");
station = keyboard.nextInt();
//change the channel on the television
bigScreen.setChannel(station);
//display 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
}
}
-
Re: Constructor help
any help with this would be appreciated.
-
Re: Constructor help
Read more about Object Oriented programming from Sun. Or google it for more results
-
Re: Constructor help
thanks but i have a text book and i still dont really understand what to do. hopefully someone can explain it or show me what the code would look like so i can figure it out myself