class FortuneTeller{
public static void main(String[] args){
Fortune f = new Fortune( );
f.words= new String[]{"大吉", "中吉", ...};
f.draw( );
} }
class Fortune {
String[] words;
void draw( ){
int r = (int)(Math.random()*words.length);
System.out.println(words[r]);
} }
これらから
Fortune f1 = new Fortune();
f1.words = new String[]{"ラブラブ","新たな出会い","マンネリ","すきま風","破局"};
f1.type = "恋愛運";
f1.draw();
Fortune f2 = new Fortune();
f2.words = new String[]{"旗揚げ","昇進","現状維持","窓際送り","解雇"};
f2.type = "仕事運";
f2.draw();
Fortune f3 = new Fortune();
f3.words = new String[]{"一攫千金","小金持ち","ちりも積もれば...","赤字","自己破産"};
f3.type = "金銭運";
f3.draw();
を加え拡張for文を使って表示するにはどうすればいいですか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/28 02:05