Jobs The first time the Java job

Source: Internet
Author: User

1. Design a class that requires a few basic attributes and more than two methods.

(Can be extracted from daily life)

2. Add 2 construction methods for different parameters in a class. 3. Re-design a class that contains the main method to apply the above class and

Test.

4. The job requires programming and debugging through. 5. You should have a detailed description of the class you are designing (what the class encapsulates,

property, the function and meaning of the method, etc.).

1 /*what the class encapsulates: adjust the player's channel and switch status2 * Properties: Height, lower channel, open/close player3  */4  PackageHomework;//stored in the homework package on my Computer5 6  Public classno01homework {//Public Method No01homework7      Public Static voidMain (string[] args) {//Main Method8Browser Browser1 =NewBrowser ();9System.out.println ("The Browser1 ' s channel is" +browser1.channel);TenBrowser Browser2 =NewBrowser (100); OneSystem.out.println ("The Browser2 ' s channel is" +browser2.channel); A          - Browser1.turnon (); -Browser1.setchannel (25); theSystem.out.println ("The Browser1 ' s channel now is" +browser1.channel); -          - Browser1.channelup (); -System.out.println ("The Browser1 ' s channel now is" +browser1.channel); +          - Browser1.channeldown (); +System.out.println ("The Browser1 ' s channel now is" +browser1.channel); A          at Browser1.turnoff (); -     } - } -      -      -     classBrowser {//To create a browser method in         intChannel//define int variable channel -         BooleanOn =false;//To define a Boolean variable false to          +Browser () {//default constructor -Channel = 1; the         } *          $Browser (intNewchannel) {//ConstructorPanax NotoginsengChannel =Newchannel; -         } the          +          Public voidTurnOn () {//function: Open player AOn =true; the         } +          -          Public voidTurnoff () {//function: Close player $On =false; $         } -          -          Public voidSetchannel (intNewchannel) {//function: Set new channel the             if(On && newchannel >= 1 && newchannel <= 100)     -Channel =Newchannel;Wuyi         } the          -          Public voidChannelup () {//function: Raise one channel Wu             if(on && Channel < 100) -channel++; About         } $          -          Public voidChanneldown () {//function: Cut one channel -             if(On && channel > 1) -channel--; A         } +     } the  -         

Jobs The first time the Java job

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.