?? testhorse.java
字號:
package CF;
abstract class Horse {
String color;
int age;
String getcolor() {
return color;
}
int getage() {
return age;
}
abstract String horsefood();
}
class WhiteHorse extends Horse {
String food = "grass";
public WhiteHorse(String str, int i) {
color = str;
age = i;
}
String horsefood() {
return food;
}
}
class RedHorse extends Horse {
String food = "meat";
public RedHorse(String str, int i) {
color = str;
age = i;
}
String horsefood() {
return food;
}
}
public class TestHorse {
Horse getType(){
WhiteHorse c = new WhiteHorse("White", 103);
return c;
}
public static void main(String[] args) {
WhiteHorse c = new WhiteHorse("White", 103);
System.out.println(c.getcolor());
System.out.println(c.getage());
System.out.println(c.horsefood());
RedHorse r = new RedHorse("red", 3);
System.out.println(r.getcolor());
System.out.println(r.getage());
System.out.println(r.horsefood());
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -