Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Random myRand = new Random();
            int length = 100; //sets the number of times the game will be played before declaring a winner
            
            Player Player1 = new Player();
            Player Player2 = new Player();

            for (int i = 0; i < length; i++)
            {
                Player1.Act(myRand);
                Player2.Act(myRand);
                Game.Fight(Player1, Player2);
            }

            string winner = "";
            if (Player1.Score > Player2.Score)
            {
                winner = "Player 1 is the Champion!!";
            }
            else if (Player1.Score < Player2.Score)
            {
                winner = "Player 2 is the Champion!!";
            }
            else
            {
                winner = "You're both Champions!!";
            }

            Console.WriteLine(string.Format("\nWe have a winner!! {0}", winner));
            Console.WriteLine(string.Format("Player 1: {0}, Player 2: {1}", Player1.Score, Player2.Score));

            //pause
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Random myRand = new Random();
            int    length = 100; //sets the number of times the game will be played before declaring a winner

            Player Player1 = new Player();
            Player Player2 = new Player();

            for (int i = 0; i < length; i++)
            {
                Player1.Act(myRand);
                Player2.Act(myRand);
                Game.Fight(Player1, Player2);
            }

            string winner = "";

            if (Player1.Score > Player2.Score)
            {
                winner = "Player 1 is the Champion!!";
            }
            else if (Player1.Score < Player2.Score)
            {
                winner = "Player 2 is the Champion!!";
            }
            else
            {
                winner = "You're both Champions!!";
            }

            Console.WriteLine(string.Format("\nWe have a winner!! {0}", winner));
            Console.WriteLine(string.Format("Player 1: {0}, Player 2: {1}", Player1.Score, Player2.Score));

            //pause
            Console.ReadLine();
        }
Ejemplo n.º 3
0
 public string TheFight(Player playerOne, Player playerTwo) {
     if (playerOne.Act() == playerTwo.Act()) {
         return "It's a draw!";
     } else if (playerOne.Act() == "Scissors" && playerTwo.Act() == "Paper") {
         return String.Format("Player {0} wins with {1} against {2}", playerOne.PlayerNum, playerOne.Act(), playerTwo.Act());
     } else if (playerTwo.Act() == "Scissors" && playerOne.Act() == "Paper") {
         return String.Format("Player {0} wins with {1} against {2}", playerTwo.PlayerNum, playerTwo.Act(), playerOne.Act());
     } else if (playerOne.Act() == "Rock" && playerTwo.Act() == "Scissors") {
         return String.Format("Player {0} wins with {1} against {2}", playerOne.PlayerNum, playerOne.Act(), playerTwo.Act());
     } else if (playerTwo.Act() == "Rock" && playerOne.Act() == "Scissors") {
         return String.Format("Player {0} wins with {1} against {2}", playerTwo.PlayerNum, playerTwo.Act(), playerOne.Act());
     } else if (playerOne.Act() == "Paper" && playerTwo.Act() == "Rock") {
         return String.Format("Player {0} wins with {1} against {2}", playerOne.PlayerNum, playerOne.Act(), playerTwo.Act());
     } else {
         return String.Format("Player {0} wins with {1} against {2}", playerTwo.PlayerNum, playerTwo.Act(), playerOne.Act());
     } 
 }
Ejemplo n.º 4
0
 // Pass Object as a Parameter?
 // What Data Type???
 // cannot be Object type because the Act() method would be blocked.
 //
 public void Fight( Player Player1, Player Player2 )
 {
     Player1.Act();
     Player2.Act();
 }
Ejemplo n.º 5
0
 // What Data Type???
 // cannot be Object type because the Act() method would be blocked.
 //
 public void Fight(Player Player1, Player Player2)   // Pass Object as a Parameter?
 {
     Player1.Act();
     Player2.Act();
 }