예제 #1
0
 public static string WriteOutResultsFromGame(Matchresults resultsFromGame)
 {
     return($"Total Games: {resultsFromGame.CountMatches}" + Environment.NewLine +
            $"Points: {resultsFromGame.CountPoints}" + Environment.NewLine +
            $"Wins: {resultsFromGame.CountWinMatches}" + Environment.NewLine +
            $"Lost: {resultsFromGame.CountEvenMatches}" + Environment.NewLine +
            $"Ewen: {resultsFromGame.CountLostMatches}" + Environment.NewLine +
            $"-----------------------------------");
 }
예제 #2
0
        public Matchresults GeMatcResults(int _countPoints, int _countMatches,
                                          int _countWinMatches, int _countEvenMatches, int _countLostMatches)
        {
            var getResultFromGame = new Matchresults()
            {
                CountPoints      = _countPoints,
                CountMatches     = _countMatches,
                CountWinMatches  = _countWinMatches,
                CountEvenMatches = _countEvenMatches,
                CountLostMatches = _countLostMatches,
            };

            return(getResultFromGame);
        }
예제 #3
0
 static void Main(string[] args)
 {
     Console.WriteLine("Write a number and press enter");
     while (true)
     {
         Matchresults results      = new Matchresults();
         string       test         = Console.ReadLine();
         var          arrayCreated = results.CreatArray(test);
         if (arrayCreated.Count > 0)
         {
             var resultsFromGame = results.TotalAmountOfPoints(arrayCreated, results);
             Console.WriteLine(Matchresults.WriteOutResultsFromGame(resultsFromGame));
         }
         else
         {
             Console.WriteLine("Must be a number");
         }
     }
 }
예제 #4
0
 public Matchresults TotalAmountOfPoints(List <string> listOfgames, Matchresults result)
 {
     foreach (var item in listOfgames)
     {
         var   splitByColonMatches     = item.Split(':');
         int[] convertToInArrayMatches = Array.ConvertAll(splitByColonMatches, int.Parse);
         if (convertToInArrayMatches[0] > convertToInArrayMatches[1])
         {
             result.CountPoints += 3;
             result.CountWinMatches++;
         }
         if (convertToInArrayMatches[0] < convertToInArrayMatches[1])
         {
             result.CountLostMatches++;
         }
         if (convertToInArrayMatches[0] == convertToInArrayMatches[1])
         {
             result.CountPoints += 1;
             result.CountEvenMatches++;
         }
         result.CountMatches++;
     }
     return(result.GeMatcResults(result.CountPoints, result.CountMatches, result.CountWinMatches, result.CountEvenMatches, result.CountLostMatches));
 }