package com.homework.zw;
//类Cat部分
public class Cat
{
String name="妮妮";
String skin="灰色";
int age =2;
void outputname()
{
System.out.println("这只猫咪的名字叫:"+name);
}
void outputhanjiao()
{
System.out.println("喵喵....");
}
}
package com.homework.zw;
//主类部分
public class TextCAT
{
public static void main(String[] args)
{
Cat nini = new Cat();
System.out.println("年龄:"+nini.age);
System.out.println("毛色:"+nini.skin);
nini.outputname();
nini.outputhanjiao();
}
}
时间: 2024-10-29 02:53:32