Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Games.HorseRace
- {
- class Program
- {
- private static List<Player> _players = new List<Player>();
- private const int TOTAL_PLAYERS = 4;
- static void Main(string[] args)
- {
- Console.Write("{0,2}", "");
- for (int i = 0; i < TOTAL_PLAYERS; i++)
- {
- _players.Add(new Player() { CurrentScore = 0 });
- Console.Write("{0,4}[+N]", "P" + (i + 1));
- }
- Console.WriteLine();
- Random rand = new Random();
- bool gameover = false;
- int t = 1;
- while (!gameover)
- {
- Console.Write("{0,2}", t);
- foreach (Player p in _players)
- {
- int r = rand.Next(1, 7);
- if ((p.CurrentScore + r) % 10 != 0)
- {
- p.CurrentScore += r;
- if (p.CurrentScore >= 86) gameover = true;
- Console.Write("{0,4}[+{1}]", p.CurrentScore, r);
- }
- else
- {
- Console.Write("{0,4}[+{1}]", "-", r);
- }
- }
- Console.WriteLine();
- t++;
- }
- if (gameover)
- {
- Console.Write("{0,2}", "");
- foreach (Player p in _players)
- {
- Console.Write("{0,8}",
- p.CurrentScore >= 86 &&
- p.CurrentScore == _players.Max(r => r.CurrentScore) ?
- "WINNER" :
- "");
- }
- Console.WriteLine();
- }
- }
- protected class Player
- {
- public int CurrentScore { get; set; }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement