Dark Horse Basic Stage quiz: Create phone class, the phone class contains the following:

Source: Internet
Author: User

 PackageCom.swift; Public classPhone {PrivateString Pinpai; Private intDianliang;  PublicString Getpinpai () {returnPinpai; }     Public voidSetpinpai (String pinpai) { This. Pinpai =Pinpai; }     Public intGetdianliang () {returnDianliang; }     Public voidSetdianliang (intDianliang) {         This. Dianliang =Dianliang; }         Public voidCheckpower () {if( This. Getdianliang () <20) {System.out.println ("Power is too low, please recharge"); }    }}

 PackageCom.swift;classtest{ Public Static voidMain (string[] args) {/** Create phone class, the phone class contains the following: * Member properties: *string type of brand *int type of remaining power *set and get method * Non-static no parameter member method with no return value: *checkpower ().         In-method implementation: Determine the current object's remaining power, if the remaining power is less than 20, then the console printing "low battery, please charge."         * Create test class, complete the following test in the Main method: *a) Create 1 phone objects with the property assigned to: Brand: "IPhone", Power: "15".         *B) Call the Checkpower () method with this object after the creation is complete. *ps: Console Print Example*/Phone Phone=NewPhone (); Phone.setpinpai ("IPhone"); Phone.setdianliang (15);    Phone.checkpower (); }}

Dark Horse Basic Stage quiz: Create phone class, the phone class contains the following:

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.