1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
import java.lang.*; //C#に合わせる為使用。普段は省略
class Rei16_2{
public static void main(String[] args){
MagicWorld yota, yokuto;
yota = new MagicWorld();
yokuto = yota;
System.out.println
("まずはyotaさんから移動するです〜");
yota.nextStage(16);
System.out.println
("次にyokutoさんが移動するです〜");
yokuto.nextStage(12);
System.out.println
("二人の居場所はそれぞれ・・・");
yota.nowStagePrintln();
yokuto.nowStagePrintln();
}
}
class MagicWorld{
private int stage;
public void nextStage(int stage){
this.stage = stage;
}
public void nowStagePrintln(){
System.out.println
("現在" + stage + "番目の部屋にいます");
}
}
|
using System;
class Rei16_2{
static void Main(){
MagicWorld yota, yokuto;
yota = new MagicWorld();
yokuto = yota;
Console.WriteLine
("まずはyotaさんから移動するです〜");
yota.nextStage(16);
Console.WriteLine
("次にyokutoさんが移動するです〜");
yokuto.nextStage(12);
Console.WriteLine
("二人の居場所はそれぞれ・・・");
yota.nowStagePrintln();
yokuto.nowStagePrintln();
}
}
class MagicWorld{
private int stage;
public void nextStage(int stage){
this.stage = stage;
}
public void nowStagePrintln(){
Console.WriteLine
("現在" + stage + "番目の部屋にいます");
}
}
|