January 21-Practice Interface PC CPU

Source: Internet
Author: User

1. Defining the interface

 Package Com.lianxi;  Public Interface ICPU {        public string Pinpai (string a) ;   brand public        void yunxing ();   Run public        int luosigeshu (int d);   number of screws     }

2. Defining computers

 PackageCom.lianxi; Public classJSJ {PrivateICPU CPU;//naming         Publicicpu getcpu () {returnCPU; }                                //Getter and Setter     Public voidSetCpu (Icpu CPU) { This. CPU =CPU; }    PrivateString Neicun;//Defining Properties        PrivateString Yingpan;//Defining Properties             PublicString Getneicun () {returnNeicun; }     Public voidSetneicun (String neicun) { This. Neicun =Neicun; }     PublicString Getyingpan () {returnYingpan;//Getter and Setter    }     Public voidSetyingpan (String yingpan) { This. Yingpan =Yingpan; }             voidKaiji ()//Defining Methods{intelcpu inte=Newintelcpu ();                Inte.yunxing (); System.out.println ("Powering on"); }             voidGuanji ()//Defining Methods{System.out.println ("Shutting down"); }        intJisuan (intAintb//Defining Methods    {        return(A +b); }    }

3. Define CPU

 PackageCom.lianxi; Public classIntelcpuImplementsicpu {@Override PublicString Pinpai (String a)//Brand Realization    {        returnA; } @Override Public voidYunxing ()//implementation Run{System.out.println ("CPU starts running"); } @Override Public intLuosigeshu (intD//number of screws implemented    {        //TODO Auto-generated method stubs        returnD; }}

4. Instantiate and run

 PackageCom.lianxi; Public classTESTJSJ { Public Static voidMain (string[] args) {JSJ JSJ=NewJSJ (); Jsj.setyingpan ("500G"); Jsj.setneicun ("Acura Memory"); INTELCPU CPU=Newintelcpu (); intA =cpu.luosigeshu (5); String b= Cpu.pinpai ("Intel card");                        Jsj.kaiji (); intc = Jsj.jisuan (5, 6); System.out.println ("Computer hard drive =" +Jsj.getyingpan ()); System.out.println ("Computer memory is" +Jsj.getneicun ()); System.out.println ("Cup on a total of" + A + "screws"); System.out.println ("The brand of the CPU is" +b); System.out.println ("The result of calculation 5 + 6 is" +c);                Jsj.guanji (); /*The result of the operation is as follows: The CPU starts to run the computer hard disk = 500G computer memory is the best memory bar on a total of 5 screws CPU brand is the Intel card The result of calculation 5 + 6 is that 11 is shutting down*/                    }}

January 21-Practice Interface PC CPU

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.