Java application little practice, kitten

Source: Internet
Author: User
Tags getcolor

 PackageLianxiti; Public classCat {PrivateString name; PrivateString color; Private intAge ;  PublicString GetName () {returnname; }     Public voidsetName (String name) { This. name=name; }     PublicString GetColor () {returncolor; }     Public voidsetcolor (String color) { This. color=color; }     Public intGetage () {returnAge ; }     Public voidSetage (intAge ) {         This. Age =Age ; }        //Behavior//Display Name     Public voidShowName () {System.out.println ("The cat's name is:" + This. Name); }    //called     Public voidshout () {System.out.println ("Meow ... "); }        //Construction Method     PublicCat (String name,string color,intAge ) {         This. name=name;  This. color=color;  This. age=Age ; }             PublicCat (String name) {Super();  This. Name =name; }     Public Static voidMain (string[] args) {Cat C1=NewCat ("Nicole"); C1.setcolor (Grey); C1.setage (2); System.out.println (The color of "cat" +c1.getname () + "is:" +C1.getcolor ()); System.out.println (The age of "cat" +c1.getname () + "is:" +c1.getage () + "old");        C1.showname ();            C1.shout (); }    }

Java application little practice, kitten

Related Article

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.