Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- var players = new List<Player>();
- players.Add(new Player("Spelare1"));
- players.Add(new Player("Spelare2"));
- }
- public void StartGame(IEnumerable<Player> players)
- {
- foreach (var player in players)
- {
- while (player.throwCount <= 3)
- {
- // Do game logic
- var score = 45;
- // Set score
- player.Score.Add(score);
- player.throwCount++;
- }
- }
- // Get the winner based on the sum of scores
- var winner = players.OrderByDescending(p => p.Score.Sum(s => s)).First();
- }
- public class Player
- {
- public string Name { get; set; }
- public int throwCount { get; set; }
- public List<int> Score { get; set; }
- public Player(string name)
- {
- Name = name;
- throwCount = 1;
- }
- public Player()
- {
- throwCount = 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment