0
0

More than 1 year has passed since last update.

vistaでandroid studio その4

Last updated at Posted at 2022-08-29

概要

vistaでandroid studio 1.0.1やってみた。
練習問題やってみた。

練習問題

ズンドコを実装せよ。

方針

  • 乱数 new Random

写真

device-2022-08-29-093621.png

サンプルコード

    public void run(View view) {
        TextView tv = (TextView) findViewById(R.id.chage);
        final String success = "ズンズンズンズンドコ";
        final List<String> zundoko = Arrays.asList("ズン", "ドコ");
        StringBuilder sb = new StringBuilder();
        Random rand = new Random();
        while (true)
        {
            String zd = zundoko.get(rand.nextInt(2));
            sb.append(zd);
            if (zd.equals("ドコ"))
            {
                String check = sb.toString();
                if (check.endsWith(success))
                {
                    sb.append(" キヨシ!!");
                    break;
                }
                sb.setLength(0);
            }
        }
        tv.setText(sb.toString());
    }

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0