Advertisement
fbinnzhivko

02.01.The Football Statician

Apr 15th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.05 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3.  
  4. public class TheFootballStatistician
  5. {
  6.     public static void Main()
  7.     {
  8.         const int PointsPerWin = 3;
  9.         const int PointsPerDraw = 1;
  10.  
  11.         decimal paymentPerMatch = decimal.Parse(Console.ReadLine());
  12.  
  13.         int arsenalPoints = 0;
  14.         int chelseaPoints = 0;
  15.         int manchesterCityPoints = 0;
  16.         int manchesterUnitedPoints = 0;
  17.         int liverpoolPoints = 0;
  18.         int evertonPoints = 0;
  19.         int southamptonPoints = 0;
  20.         int tottenhamPoints = 0;
  21.  
  22.         int matchesCounter = 0;
  23.         while (true)
  24.         {
  25.             string inputLine = Console.ReadLine();
  26.             if (inputLine == "End of the league.")
  27.             {
  28.                 break;
  29.             }
  30.  
  31.             string[] arguments = inputLine.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  32.             string firstTeam = arguments[0];
  33.             string secondTeam = arguments[2];
  34.             string matchResult = arguments[1];
  35.  
  36.             if (matchResult == "1")
  37.             {
  38.                 arsenalPoints = AddingPointsToTeam(
  39.                     firstTeam,
  40.                     arsenalPoints,
  41.                     PointsPerWin,
  42.                     ref chelseaPoints,
  43.                     ref manchesterCityPoints,
  44.                     ref manchesterUnitedPoints,
  45.                     ref liverpoolPoints,
  46.                     ref evertonPoints,
  47.                     ref southamptonPoints,
  48.                     ref tottenhamPoints);
  49.             }
  50.             else if (matchResult == "2")
  51.             {
  52.                 arsenalPoints = AddingPointsToTeam(
  53.                     secondTeam,
  54.                     arsenalPoints,
  55.                     PointsPerWin,
  56.                     ref chelseaPoints,
  57.                     ref manchesterCityPoints,
  58.                     ref manchesterUnitedPoints,
  59.                     ref liverpoolPoints,
  60.                     ref evertonPoints,
  61.                     ref southamptonPoints,
  62.                     ref tottenhamPoints);
  63.             }
  64.             else
  65.             {
  66.                 arsenalPoints = AddingPointsToTeam(
  67.                     firstTeam,
  68.                     arsenalPoints,
  69.                     PointsPerDraw,
  70.                     ref chelseaPoints,
  71.                     ref manchesterCityPoints,
  72.                     ref manchesterUnitedPoints,
  73.                     ref liverpoolPoints,
  74.                     ref evertonPoints,
  75.                     ref southamptonPoints,
  76.                     ref tottenhamPoints);
  77.  
  78.                 arsenalPoints = AddingPointsToTeam(
  79.                     secondTeam,
  80.                     arsenalPoints,
  81.                     PointsPerDraw,
  82.                     ref chelseaPoints,
  83.                     ref manchesterCityPoints,
  84.                     ref manchesterUnitedPoints,
  85.                     ref liverpoolPoints,
  86.                     ref evertonPoints,
  87.                     ref southamptonPoints,
  88.                     ref tottenhamPoints);
  89.             }
  90.  
  91.             matchesCounter++;
  92.         }
  93.  
  94.         decimal priceForAllMatchesInLeva = (matchesCounter * paymentPerMatch) * 1.94m;
  95.  
  96.         Console.WriteLine("{0:f2}lv.", priceForAllMatchesInLeva);
  97.         Console.WriteLine("Arsenal - {0} points.", arsenalPoints);
  98.         Console.WriteLine("Chelsea - {0} points.", chelseaPoints);
  99.         Console.WriteLine("Everton - {0} points.", evertonPoints);
  100.         Console.WriteLine("Liverpool - {0} points.", liverpoolPoints);
  101.         Console.WriteLine("Manchester City - {0} points.", manchesterCityPoints);
  102.         Console.WriteLine("Manchester United - {0} points.", manchesterUnitedPoints);
  103.         Console.WriteLine("Southampton - {0} points.", southamptonPoints);
  104.         Console.WriteLine("Tottenham - {0} points.", tottenhamPoints);
  105.     }
  106.  
  107.     private static int AddingPointsToTeam(
  108.         string team,
  109.         int arsenalPoints,
  110.         int pointsToAdd,
  111.         ref int chelseaPoints,
  112.         ref int manchesterCityPoints,
  113.         ref int manchesterUnitedPoints,
  114.         ref int liverpoolPoints,
  115.         ref int evertonPoints,
  116.         ref int southamptonPoints,
  117.         ref int tottenhamPoints)
  118.     {
  119.         switch (team)
  120.         {
  121.             case "Arsenal":
  122.                 arsenalPoints += pointsToAdd;
  123.                 break;
  124.             case "Chelsea":
  125.                 chelseaPoints += pointsToAdd;
  126.                 break;
  127.             case "ManchesterCity":
  128.                 manchesterCityPoints += pointsToAdd;
  129.                 break;
  130.             case "ManchesterUnited":
  131.                 manchesterUnitedPoints += pointsToAdd;
  132.                 break;
  133.             case "Liverpool":
  134.                 liverpoolPoints += pointsToAdd;
  135.                 break;
  136.             case "Everton":
  137.                 evertonPoints += pointsToAdd;
  138.                 break;
  139.             case "Southampton":
  140.                 southamptonPoints += pointsToAdd;
  141.                 break;
  142.             case "Tottenham":
  143.                 tottenhamPoints += pointsToAdd;
  144.                 break;
  145.         }
  146.  
  147.         return arsenalPoints;
  148.     }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement