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.IO;
- namespace ZaliczenieP7
- {
- class Program
- {
- public class Player
- {
- public string Nick { get; set; }
- public List<decimal?> Times { get; set; }
- public List<bool> Passed { get; set; }
- }
- static void Main(string[] args)
- {
- Console.WriteLine("Podaj liczbę etapów: ");
- int RoundCount = int.Parse(Console.ReadLine());
- Console.Clear();
- Console.WriteLine("Zawodnik 1: ");
- string name1 = Console.ReadLine();
- Player player1 = new Player() { Nick = name1 }
- Console.WriteLine("Zawodnik 2: ");
- string name2 = Console.ReadLine();
- Player player2 = new Player() { Nick = name2 }
- Console.WriteLine("Zawodnik 3: ");
- string name3 = Console.ReadLine();
- Player player3 = new Player() { Nick = name3 }
- void Start()
- {
- List<Player> Round = new List<Player>();
- Console.WriteLine($"Czas zawodnika {player1.Nick}:");
- int time1 = int.Parse(Console.ReadLine());
- player1.Times.Add(time1);
- Console.WriteLine($"Czas zawodnika {player2.Nick}:");
- int time2 = int.Parse(Console.ReadLine());
- player2.Times.Add(time2);
- Console.WriteLine($"Czas zawodnika {player3.Nick}:");
- int time3 = int.Parse(Console.ReadLine());
- player3.Times.Add(time3);
- Round.Add(player1);
- Round.Add(player2);
- Round.Add(player3);
- foreach (Player player in Round.OrderBy(x => x.Times[RoundCount - 1]))
- {
- if (player.Times[RoundCount] != 0)
- {
- Console.WriteLine($"Zawodnik: {player.Nick} Czas: {player.Times[RoundCount - 1]}");
- player.Passed.Add(true);
- }
- else
- {
- Console.WriteLine($"Zawodnik: {player.Nick} nie ukończył etapu");
- player.Passed.Add(false);
- }
- }
- Console.ReadKey();
- }
- for (int i = 1; i < RoundCount + 1; i++)
- {
- Console.WriteLine($"Runda {i}");
- Start();
- }
- bool player1Pass;
- foreach(bool pass from player1.Passed)
- {
- if(pass = false)
- {
- player1Pass = false;
- break;
- }
- }
- if(player1Pass == false))
- {
- Console.WriteLine(player1.Nick + " to straszny zjeb");
- }
- else
- {
- decimal result = 0;
- foreach(decimal time in player1.Times)
- {
- result += time;
- }
- Console.WriteLine(player1.Nick + " osiągnął końcowy wynik: " + result);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement