Results 1 to 4 of 4

Thread: Constructor help

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    2

    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


    }
    }

  2. #2

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    2

    Re: Constructor help

    any help with this would be appreciated.

  3. #3
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  4. #4

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    2

    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
  •  



Click Here to Expand Forum to Full Width