Football

in #ita5 months ago

using System;

using System.Collections.Generic;

public static class PlayAnalyzer

{

public static string AnalyzeOnField(int shirtNum)

{

    switch (shirtNum)

    {

        case 1: 

            return "goalie";

            break;

        case 2: 

            return "left back";

            break;

        case 3:

        case 4: 

            return "center back";

            break;

        case 5: 

            return "right back";

            break;

        case 6:

        case 7: 

        case 8: 

            return "midfielder";

            break;

        case 9:

            return "left wing";

            break;

        case 10: 

            return "striker";

            break;

        case 11: 

            return "right wing";

            break;

        default:

            throw new ArgumentOutOfRangeException($"Too big number");

    }

    return "no";

} 

public static string AnalyzeOffField(object report)

{

     string returnStringFirst = "There are ";

     string returnStringSec = " supporters at the match.";

     switch(report)

     {

         case int: 

             string reportString = report.ToString();

             return returnStringFirst + reportString + returnStringSec;

           

        case string: 

            string reportTransf = report.ToString();

            return reportTransf;

        case Injury inj:

            return "Oh no! "+inj.GetDescription()+ " Medics are on the field.";

             

        case Incident i:

            return i.GetDescription(); // metodo di una classe esterna Incident

        case Manager m when m.Club == null:

            return m.Name;

        case Manager m:

            return m.Name+ " (" + m.Club+")";

        

        default: 

            throw new ArgumentException(report.ToString());

    }

}

}