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