public void ResultComparator(BasketballPlayer a, Sportsman b) { int i = ((IComp <BasketballPlayer, Sportsman>)a).Comparator(a, b); switch (i) { case 1: FirstNotify?.Invoke($"Name {a.Name} is longer than {b.Name}"); break; case -1: FirstNotify?.Invoke($"Name {b.Name} is longer than {a.Name}"); break; case 0: FirstNotify?.Invoke($" {a.Name} is equal to {b.Name} length"); break; default: FirstNotify?.Invoke("I guess there was a mistake"); break; } }
int IComp <BasketballPlayer, Sportsman> .Comparator(BasketballPlayer a, Sportsman b) { if (a.Name.Length > b.Name.Length) { return(1); } if (a.Name.Length < b.Name.Length) { return(-1); } if (a.Name.Length == b.Name.Length) { return(0); } return(2); }
public void GetWinner(BasketballPlayer bk1, BasketballPlayer bk2) { if (bk1.GetIntPoints() > bk2.GetIntPoints()) { SecondNotify?.Invoke($"\n\n{bk1.Name} is winner \n\n\n"); } else { if (bk2.GetIntPoints() > bk1.GetIntPoints()) { SecondNotify?.Invoke($"\n\n{bk2.Name} is winner \n\n\n"); } else { if (bk1.GetIntPoints() == bk2.GetIntPoints()) { SecondNotify?.Invoke("\n\nDraw game!\n\n\n"); } } } }
public void FinalScore(BasketballPlayer bk1, BasketballPlayer bk2) { SecondNotify?.Invoke($"\n\n{bk1.Name} scored {bk1.GetIntPoints()} points"); SecondNotify?.Invoke($"{bk2.Name} scored {bk2.GetIntPoints()} points\n\n\n"); }