MuffinMonster

Class Task 35#

Nov 18th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int cube1, cube2, min = int.MaxValue, players, tot = 0, winner = 0;
  13.             Console.Write("Enter the amount of people who are going to play: ");
  14.             players = int.Parse(Console.ReadLine());
  15.             Random r = new Random();
  16.             for (int i = 1; i <= players;i++)
  17.             {
  18.                 Console.WriteLine("Player " + i + " turn");
  19.                 Console.Write("Your turn! Press enter to play to throw your first cube!");
  20.                 Console.ReadKey();
  21.                 cube1 = r.Next(1, 7);
  22.                 Console.WriteLine(cube1);
  23.                 Console.Write("Your turn! Press enter to play to throw your second cube!");
  24.                 Console.ReadKey();
  25.                 cube2 = r.Next(1, 7);
  26.                 Console.WriteLine(cube2);
  27.                 tot = tot + cube2 + cube1;
  28.                 while (cube1 != cube2)
  29.                 {
  30.                     Console.Write("Your turn! Press enter to play to throw your first cube!");
  31.                     Console.ReadKey();
  32.                     cube1 = r.Next(1, 7);
  33.                     Console.WriteLine(cube1);
  34.                     Console.Write("Your turn! Press enter to play to throw your second cube!");
  35.                     Console.ReadKey();
  36.                     cube2 = r.Next(1, 7);
  37.                     Console.WriteLine(cube2);
  38.                     tot = tot + cube2 + cube1;
  39.                 }
  40.                 if (tot < min)
  41.                 {
  42.                     min = tot;
  43.                     winner = i;
  44.                 }
  45.             }
  46.             Console.WriteLine(min);
  47.             Console.WriteLine("Player " + winner + "# wins!");
  48.             Console.ReadKey();
  49.         }
  50.     }
  51. }
Add Comment
Please, Sign In to add comment