今天开始面向对象的第一天,学习新知识!
class Dog{
String name;
int age;
publuc (){};
public(int age,String name){
this.name=name;
this.age=age;
}
public void play(){
System.out.println("小狗正在玩耍");
}
public void habit(){
System.out.println("小狗喜欢吃骨头")
}
public void show(){
System.out.println("姓名:"+name+"\t年龄:"+age)
}
public static void main(String[] args){
Dog a=new Dog();
a.name="小黄";
a.age="三个月";
a.play();
a.habit();
a.show();
Dog b=new Dog("小黄","四个月");
b.habit();
b.play();
b.show();
}
}