Esempio n. 1
0
        public void AveragePrice(Footballer footballer)
        {
            numOfPlayers++;
            totalPrice += footballer.price;

            average = totalPrice / numOfPlayers;
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            PriceTotaller priceTotaller = new PriceTotaller();                                      //New Instance/Default Constructor

            FootballerDatabase footballerDB = new FootballerDatabase();                             //New Instance/Default Constructor

            Footballer footballer1 = new Footballer("Ben Bowes", "Middlesbrough", 10000.00, false); //Making footballers
            Footballer footballer2 = new Footballer("Andrew Norman", "Middlesbrough", 1000.00, false);
            Footballer footballer3 = new Footballer("Spencer Newton", "Middlesbrough", 100.00, false);
            Footballer footballer4 = new Footballer("Bishan Meghani", "Middlesbrough", 10.00, true);

            footballerDB.AddFootballer(footballer1);        //Adding to database
            footballerDB.AddFootballer(footballer2);
            footballerDB.AddFootballer(footballer3);
            footballerDB.AddFootballer(footballer4);

            ProcessPlayerDelegate myDelegate =
                new ProcessPlayerDelegate(priceTotaller.AddFootballersPriceToTotal);        //Constructor for the Delegate

            footballerDB.ProcessInjuredPlayers(myDelegate);

            ProcessPlayerDelegate myPrintDelegate =
                new ProcessPlayerDelegate(priceTotaller.Print);

            footballerDB.ProcessInjuredPlayers(myPrintDelegate);
        }
Esempio n. 3
0
 public void Print(Footballer footballer)
 {
     Console.WriteLine(footballer.name);
 }
Esempio n. 4
0
 public void AddFootballersPriceToTotal(Footballer footballer) //Performs what the delegate wants (returns void and uses footballer)
 {
     totalPrice += footballer.price;
 }
Esempio n. 5
0
        List <Footballer> transferlist = new List <Footballer>();   //LIST

        public void AddFootballer(Footballer footballerToAdd)       //Adding to LIST
        {
            transferlist.Add(footballerToAdd);
        }