Beispiel #1
0
        }// end of playGame1_V2

        static private void playGame1_V3()
        {
            int result1, result2 = 0; //1

            try                       //2
            {
                GoodDice player1;
                player1 = new GoodDice("Blue"); //3
                result1 = player1.Num;          //4

                GoodDice player2;
                player2 = new GoodDice("Red"); //3
                result2 = player2.Num;         //4

                if (player1.Num > player2.Num)
                {
                    Console.WriteLine("Player 1 rolled " + player1.ToString());
                }
                else
                {
                    Console.WriteLine("Player 2 rolled " + player2.ToString());
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error " + e.Message);
            }
        }// end of playGame1_V3
Beispiel #2
0
        }// end of playGame1_V1

        static private void playGame1_V2()  //1
        {
            int result1 = 0;

            try                                                                             //2
            {
                GoodDice player1 = new GoodDice();                                          //3
                player1.Num    = 0;                                                         //4
                player1.Colour = "asedgfvfSDFDVSSDVsfvd£";                                  //4b
                player1.GenerateNumber();                                                   //4c
                result1 = player1.Num;                                                      //5
                Console.WriteLine("Player 1 rolled " + player1.Colour + " " + player1.Num); //5b
                Console.WriteLine("Player 1 rolled " + player1.ToString());                 //5c
            }
            catch (Exception e)
            {
                Console.WriteLine("Error " + e.Message);    //2b
            }
        }// end of playGame1_V2