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