package p1;
public class TestDog{
public static void main(String[] args){
//创建对象,基于类名
Dog dog = new Dog();
//为对象的属性赋值
dog.breed="牧羊犬";
dog.age = 2;
dog.sex = true;
dog.furColor="白色";
System.out.println(dog.breed+"\t"+dog.age+"\t"+dog.sex+"\t"+dog.furColor);
//为对象赋予具体的行为
dog.eat();
dog.run();
dog.sleep();
}
}
class Dog{
//属性
String breed;
int age;
boolean sex;
String furColor;
//方法
public void eat(){
System.out.println("狗在吃骨头!!!!");
}
public void run(){
System.out.println("狗在奔跑......");
}
public void sleep(){
System.out.println("狗睡6个小时");
}
}