?? testnature.java
字號:
?
+
class TestNature {
TestNature () {
Elephant jumbo = new Elephant ("Elephant",350,1.2);
Rhino mafuta = new Rhino ("Rhino", 200, 0.75);
System.out.println (jumbo);
System.out.println (mafuta);
}
public static void main (String [] args) {
new TestNature ();
}
class Nature {
protected String name;
Nature (String n) {
name = n;
}
public String toString () {
return name;
}
}
class Animals extends Nature {
Animals (String n) {
super (n);
}
}
class Herbivores extends Animals {
protected int grassneeded;
Herbivores (String n, int g) {
super (n);
grassneeded = g;
}
}
class Elephant extends Herbivores {
private double tusks; // their length
Elephant (String name, int weight, double length) {
super (name, weight);
tusks = length;
}
public String toString () {
return name+" "+grassneeded + " "+tusks;
}
}
class Rhino extends Herbivores {
private double horn; // its length
Rhino (String n, int w, double l) {
super (n, w);
horn = l;
}
public String toString () {
return name+" "+grassneeded + " "+horn;
}
// and more on rhinos
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -