- Java復習(2)this
thread thread = new thread() {
public void run() {
system.out.println(runnable#run() start.);
privatemethod();
system.out.println(subouter.this.str= + subouter.this.str); // thisで外側のクラスの変数を参照
system.out.println(runnable#run() end.);
}
};
thread.start();
}
}
- Ruby入門7
rubyはインスタンス変数を直接外部から参照は不可
- Java:勇者vs魔王ゲーム
ublic class boss extends charactor implements wizard { boss(int hp, string name) { super(hp, name); } public int fire() { int n = (int)(math.random() * 200) + 1; return n; } public int ice() { int n = (int)(math.random() * 200) + 1; return n; } int attack() { int n = (int)(math.random() * 150) + 1; return n; } boolean dead() { if (hp 0) { return true; } else { return false; } } void damage(int d){ hp -= d; } void run_away() { system.out.println(name + は逃げました ); system.exit(0); } } 次はインターフェース(表記はインターフェイスじゃダメなのかな?)で・・・ 戦士インターフェイスのソースです
|