封装问题,程序没报错却无法正常输出结果,请教
下面的程序没有编码错误,但为什么无法输出结果呢/class GoodDog {
private int size;
public int getSize() {
return size;
}
public void setSize(int s) {
size=s;
}
void bark() {
if(size>60) {
System.out.println("Woof!Woof");
}else if(size>14) {
System.out.println("Ruff!Ruff!");
}else {
System.out.println("Yip!Yip!");
}
}
}
class GoodDogTestDrive{
public static void main(String[]args) {
GoodDog one=new GoodDog();
one.setSize(70);
GoodDog two=new GoodDog();
two.setSize(8);
System.out.println("Dog one: "+one.getSize());
System.out.println("Dog two: "+two.getSize());
one.bark();
two.bark();
}
}