예제 #1
0
        static void Main(string[] args)

        {
            Console.WriteLine("welcome to the dice game");
            Console.WriteLine("plesase enter your name");
            string Name1 = Console.ReadLine();

            bool WantToPlay = false;

            Console.WriteLine("would you like to play the dice " + Name1);
            string ifplay = Console.ReadLine();

            ifplay = ifplay.ToLower();
            for (;;)
            {
                if (ifplay == "yes")
                {
                    WantToPlay = true;
                    break;
                }
                if (ifplay == "no")
                {
                    Console.WriteLine("have a nice day");
                    WantToPlay = false;
                }
                else if ((ifplay != "yes") || (ifplay != "no"))
                {
                    Console.WriteLine("please enter yes or no");
                    ifplay = Console.ReadLine();
                    ifplay = ifplay.ToLower();
                }
            }
            int                WhileLoopMonitor      = 1;
            int                GetEvenNumberPlayList = -1;
            int                GetOddNumberPlayList  = 0;
            string             Name2    = " ";
            List <RollTheDice> PlayDice = new List <RollTheDice>();

            while (WantToPlay == true)
            {
                PlayDice.Add(new RollTheDice());


                while (WhileLoopMonitor % 2 == 0)

                {
                    Console.WriteLine();
                    RollTheDice.Play1skill    = PlayDice[GetEvenNumberPlayList].Skill;
                    RollTheDice.Play1Strength = PlayDice[GetEvenNumberPlayList].Strength;
                    RollTheDice.Play2skill    = PlayDice[GetOddNumberPlayList].Skill;
                    RollTheDice.Play2Strength = PlayDice[GetOddNumberPlayList].Strength;

                    RollTheDice.Comparer();
                    //RollTheDice.MakeWinnerskill();
                    // RollTheDice.MakeWinnerStrength();

                    using (StreamWriter print = new StreamWriter("file.txt"))
                    {
                        print.WriteLine("the score for {0} is {1} skill {2} strenth", Name1, RollTheDice.Play1skill, RollTheDice.Play1Strength);
                        print.WriteLine("the score for {0} is {1} skill {2} strenth", Name2, RollTheDice.Play2skill, RollTheDice.Play2Strength);
                    }

                    break;
                }

                RollTheDice.DisplayNumOfPlayers();
                Console.WriteLine();

                while (WhileLoopMonitor == 1)
                {
                    Console.WriteLine("plesase enter your name");
                    Name2 = Console.ReadLine();
                    Console.WriteLine("would you like to play the dice {0} against {1}", Name2, Name1);
                    break;
                }
                while (WhileLoopMonitor % 2 == 0)
                {
                    Console.WriteLine("another game {0} and {1}", Name1, Name2);
                    break;
                }
                while ((WhileLoopMonitor % 2 > 0) && (WhileLoopMonitor > 1))

                {
                    Console.WriteLine("are you ready {0} ", Name2);
                    break;
                }
                string again = Console.ReadLine();
                again = again.ToLower();
                if ((again != "yes") && (again != "no"))
                {
                    Console.WriteLine("next time dont type in rubish");
                    Console.WriteLine("SEE YOU");
                    WantToPlay = false;
                    break;
                }
                if (again == "no")
                {
                    Console.WriteLine("thanks for playing");
                    WantToPlay = false;
                }
                if (again == "yes")
                {
                    WhileLoopMonitor++;
                    Console.WriteLine(WhileLoopMonitor + " WhileLoopMonitor");
                    GetEvenNumberPlayList++;
                    Console.WriteLine(GetEvenNumberPlayList + " GetEvenNumberPlayList");
                    GetOddNumberPlayList++;
                    Console.WriteLine(GetOddNumberPlayList + " GetOddNumberPlayList");
                    WantToPlay = true;
                }
            }

            Console.ReadKey();
        }
예제 #2
0
        static void Main(string[] args)

        {
            Console.WriteLine("{0:X}", 13);
            Console.WriteLine("hello world");
            Console.WriteLine("{0:G}", DayOfWeek.Wednesday);

            const int HEIGHT = 12;



            // Allocate the array in a triangle form
            long[][] triangle = new long[HEIGHT + 1][];
            for (int row = 0; row < HEIGHT; row++)
            {
                triangle[row] = new long[row + 1];
            }
            // Calculate the Pascal's triangle
            triangle[0][0] = 1;
            for (int row = 0; row < HEIGHT - 1; row++)
            {
                for (int col = 0; col <= row; col++)
                {
                    triangle[row + 1][col]     += triangle[row][col];
                    triangle[row + 1][col + 1] += triangle[row][col];
                }
            }
            // Print the Pascal's triangle
            for (int row = 0; row < HEIGHT; row++)
            {
                Console.Write("".PadLeft((HEIGHT - row) * 2));
                for (int col = 0; col <= row; col++)
                {
                    Console.Write("{0,3} ", triangle[row][col]);
                }
                Console.WriteLine();
            }
            Console.WriteLine("welcome to the dice game");
            Console.WriteLine("plesase enter your name");
            string Name1 = Console.ReadLine();

            bool WantToPlay = false;

            Console.WriteLine("would you like to play the dice " + Name1);
            string ifplay = Console.ReadLine();

            ifplay = ifplay.ToLower();
            for (;;)
            {
                if (ifplay == "yes")
                {
                    WantToPlay = true;
                    break;
                }
                if (ifplay == "no")
                {
                    Console.WriteLine("have a nice day");
                    WantToPlay = false;
                }
                else if ((ifplay != "yes") || (ifplay != "no"))
                {
                    Console.WriteLine("please enter yes or no");
                    ifplay = Console.ReadLine();
                    ifplay = ifplay.ToLower();
                }
            }
            int                WhileLoopMonitor      = 1;
            int                GetEvenNumberPlayList = -1;
            int                GetOddNumberPlayList  = 0;
            string             Name2    = " ";
            List <RollTheDice> PlayDice = new List <RollTheDice>();

            while (WantToPlay == true)
            {
                PlayDice.Add(new RollTheDice());


                while (WhileLoopMonitor % 2 == 0)

                {
                    Console.WriteLine();
                    RollTheDice.Play1skill    = PlayDice[GetEvenNumberPlayList].Skill;
                    RollTheDice.Play1Strength = PlayDice[GetEvenNumberPlayList].Strength;
                    RollTheDice.Play2skill    = PlayDice[GetOddNumberPlayList].Skill;
                    RollTheDice.Play2Strength = PlayDice[GetOddNumberPlayList].Strength;

                    RollTheDice.Comparer();
                    //RollTheDice.MakeWinnerskill();
                    // RollTheDice.MakeWinnerStrength();

                    using (StreamWriter print = new StreamWriter("file.txt"))
                    {
                        print.WriteLine("the score for {0} is {1} skill {2} strenth", Name1, RollTheDice.Play1skill, RollTheDice.Play1Strength);
                        print.WriteLine("the score for {0} is {1} skill {2} strenth", Name2, RollTheDice.Play2skill, RollTheDice.Play2Strength);
                    }

                    break;
                }

                RollTheDice.DisplayNumOfPlayers();
                Console.WriteLine();

                while (WhileLoopMonitor == 1)
                {
                    Console.WriteLine("plesase enter your name");
                    Name2 = Console.ReadLine();
                    Console.WriteLine("would you like to play the dice {0} against {1}", Name2, Name1);
                    break;
                }
                while (WhileLoopMonitor % 2 == 0)
                {
                    Console.WriteLine("another game {0} and {1}", Name1, Name2);
                    break;
                }
                while ((WhileLoopMonitor % 2 > 0) && (WhileLoopMonitor > 1))

                {
                    Console.WriteLine("are you ready {0} ", Name2);
                    break;
                }
                string again = Console.ReadLine();
                again = again.ToLower();
                if ((again != "yes") && (again != "no"))
                {
                    Console.WriteLine("next time dont type in rubish");
                    Console.WriteLine("SEE YOU");
                    WantToPlay = false;
                    break;
                }
                if (again == "no")
                {
                    Console.WriteLine("thanks for playing");
                    WantToPlay = false;
                }
                if (again == "yes")
                {
                    WhileLoopMonitor++;
                    Console.WriteLine(WhileLoopMonitor + " WhileLoopMonitor");
                    GetEvenNumberPlayList++;
                    Console.WriteLine(GetEvenNumberPlayList + " GetEvenNumberPlayList");
                    GetOddNumberPlayList++;
                    Console.WriteLine(GetOddNumberPlayList + " GetOddNumberPlayList");
                    WantToPlay = true;
                }
            }

            Console.ReadKey();
        }