📄 animal.java
字号:
package s2Java.sg.ch03.homework;
public interface Animal {
void voice();
}
class Dog implements Animal {
public void voice() {
System.out.println("W W!");
}
}
class Cat implements Animal {
public void voice() {
System.out.println("M M!");
}
}
class Store {
public static Animal get( String choice ) {
if ( choice.equalsIgnoreCase( "dog" )) {
return new Dog();
} else {
return new Cat();
}
}
}
class Pig implements Animal {
public void voice() {
System.out.println("O O!");
}
}
class Store2{
public static Animal get( String choice ) {
if ( choice.equalsIgnoreCase( "dog" )) {
return new Dog();
} else if ( choice.equalsIgnoreCase( "pig" )) {
return new Pig();
} else
return new Cat();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -