|
-
Oct 21st, 2007, 05:11 PM
#1
Thread Starter
New Member
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
}
}
-
Oct 21st, 2007, 06:02 PM
#2
Thread Starter
New Member
Re: Constructor help
any help with this would be appreciated.
-
Oct 21st, 2007, 09:29 PM
#3
Re: Constructor help
Read more about Object Oriented programming from Sun. Or google it for more results
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Oct 21st, 2007, 10:53 PM
#4
Thread Starter
New Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|