###前提・実現したいこと
観覧してくださってありがとうございます
高卒SE0年生として現在会社で勉強していて簡単なじゃんけんゲームを作成しました
そこで応用で回数指定の限定じゃんけんを作ろうとしているのですがどこを改善すれば良いかで悩んでいます
ソースコードは私が作ったじゃんけんゲームのソースコードになります
若輩者ですがアドバイスをよろしくお願いします
【追記説明】
説明不足で申し訳ないです…
(ルール)
・プレイヤーは2人(プレイヤー1・CPU1)
・9回勝負
・グー、チョキ、パー各3回までしか出せない
(手順)
・じゃんけん→勝敗判定を9回繰り返し
・勝敗をカウント
(現在の仕様)
手を決めてじゃんけんするだけの勝敗などがまだカウントできてない状況です
なるべく詳細は書いていくつもりですが説明足りないかと思いますがそのつど言って頂ければと思います
よろしくお願いします
###該当のソースコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class ゲーム//
{
static void Main(string[] args)
{
int player = 1;
int cpu = 1;
int a = 1;
string player1 = ""; string cpu1 = ""; Random rand = new Random();//乱数を設定 Console.WriteLine("数字を入力");//文字を表示 Console.WriteLine("じゃんけん\n数字を入力\n1グー、2チョキ、3パー");//文字を表示 while (a != 0)//条件が正しい場合反復処理 { try//実行 { player = int.Parse(Console.ReadLine()); cpu = rand.Next(1, 4); if (cpu == player) { Console.WriteLine("あいこ もう一度入力"); continue; } else if (player == 1 && cpu == 2) { Console.WriteLine("プレイヤー、グー"); Console.WriteLine("CPU、チョキ"); Console.WriteLine("勝ち"); } else if (player == 2 && cpu == 3) { Console.WriteLine("プレイヤー、チョキ"); Console.WriteLine("CPU、パー"); Console.WriteLine("勝ち"); } else if (player == 3 && cpu == 1) { Console.WriteLine("プレイヤー、パー"); Console.WriteLine("CPU、グー"); Console.WriteLine("勝ち"); } else if (player < 1 || player > 3) { Console.WriteLine("1か2か3を入力してね"); continue; } else { if (player == 1) player1 = player.ToString("グー"); if (player == 2) player1 = player.ToString("チョキ"); if (player == 3) player1 = player.ToString("パー"); if (cpu == 1) cpu1 = cpu.ToString("グー"); if (cpu == 2) cpu1 = cpu.ToString("チョキ"); if (cpu == 3) cpu1 = cpu.ToString("パー"); Console.WriteLine("プレイヤー、{0}\nCPU、{1}", player1, cpu1); Console.WriteLine("負け"); } //終了分岐の呼び出し bunki(ref player, ref cpu, ref a); if (a == 0) { Console.Clear(); Console.Write("終了します");//文字を表示 } } catch (FormatException) { Console.Clear(); Console.WriteLine("数字を入力");//文字を表示 Console.WriteLine("じゃんけん\n数字を入力\n1グー、2チョキ、3パー");//文字を表示 continue; } } } //終了分岐のメソッド static void bunki(ref int player, ref int cpu, ref int a) { if (player != cpu) { Console.WriteLine("\n終了なら0\n続行は0以外を入力"); a = int.Parse(Console.ReadLine()); Console.Clear(); Console.WriteLine("数字を入力");//文字を表示 Console.WriteLine("じゃんけん\n数字を入力\n1グー、2チョキ、3パー");//文字を表示 } } }
}
###補足情報(言語/FW/ツール等のバージョンなど)
VisualStudio2015