?? dogtest.java
字號(hào):
// operators/DogTest.java
// TIJ4 Chapter Operators, Exercise 5, page 105
/* Create a class called Dog containing two Strings: name and says.
* In main(), create two dog objects with names "spot" (who says "Ruff!") and
* "scruffy" (who says "Wurf!"). Then display their names and what they say.
*/
import org.greggordon.tools.*;
class Dog {
String name;
String says;
void setName(String n) {
name = n;
}
void setSays(String s) {
says = s;
}
void showName() {
P.rintln(name);
}
void speak() {
P.rintln(says);
}
}
public class DogTest {
public static void main(String[] args) {
Dog spot = new Dog();
spot.setName("Spot");
spot.setSays("Ruff!");
Dog scruffy = new Dog();
scruffy.setName("Scruffy");
scruffy.setSays("Wurf!");
spot.showName();
spot.speak();
scruffy.showName();
scruffy.speak();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -