📄 sheep.java
字号:
package chapter7;
public class Sheep extends Animal
{
private String sheepBreed = "";
private String sheepName = "";
public Sheep(String sheepBreed,String sheepName)
{
super("羊");
this.sheepBreed = sheepBreed;
this.sheepName = sheepName;
}
public Sheep()
{
super("羊");
}
public void eat(String food)
{
System.out.print("我是一只羊,");
if(!food.equals("草"))
{
System.out.println("我不吃" + food);
}
else
{
super.eat(food);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -