Skip to content

Instantly share code, notes, and snippets.

@KristupasSavickas
Created October 23, 2016 09:46
Show Gist options
  • Save KristupasSavickas/64db4d8cedf3d4b58384807e50d670b7 to your computer and use it in GitHub Desktop.
Save KristupasSavickas/64db4d8cedf3d4b58384807e50d670b7 to your computer and use it in GitHub Desktop.
cancer
namespace Uzduotis2
{
class BasketballPlayer : Player
{
public int Rebounds { get; private set; }
public int Assists { get; private set; }
public BasketballPlayer(string firstName, string lastName, int gameCount, int rebounds, int assists)
: base(firstName, lastName, gameCount)
{
Rebounds = rebounds;
Assists = assists;
}
}
}
namespace Uzduotis2
{
class BasketballTeam : Team
{
private BasketballPlayer[] Players;
public int PlayerCount { get; private set; }
public BasketballTeam(string coach, string city, int gameCount, BasketballPlayer[] players, int playerCount)
: base(coach, city, gameCount, playerCount)
{
PlayerCount = playerCount;
Players = new BasketballPlayer[playerCount];
for ( int i = 0; i < playerCount; i++)
{
Players[i] = players[i];
}
}
public BasketballPlayer GetPlayer(int index)
{
return Players[index];
}
public void AddPlayer(BasketballPlayer player)
{
Players[PlayerCount++] = player;
}
}
}
namespace Uzduotis2
{
class Player
{
public string FirstName { get; private set; }
public string LastName { get; private set; }
public int GameCount { get; private set; }
public int Points {get; private set; }
public Player(string firstName, string lastName, int gameCount)
{
FirstName = firstName;
LastName = lastName;
GameCount = gameCount;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Uzduotis2
{
class Program
{
static void Main(string[] args)
{
double basketballAverage,
soccerAverage,
averageBasketballGames,
averageSoccerGames;
List<BasketballTeam> basketballTeams;
List<SoccerTeam> soccerTeams;
List<BasketballPlayer> BTABasketballPlayers;
List<SoccerPlayer> BTASoccerPlayers;
readData(out basketballTeams, out soccerTeams);
findAverages(basketballTeams, soccerTeams, out basketballAverage, out soccerAverage, out averageBasketballGames, out averageSoccerGames);
findBTAPlayers(basketballAverage, soccerAverage, basketballTeams, soccerTeams, out BTABasketballPlayers, out BTASoccerPlayers);
}
static void readData(out List<BasketballTeam> bastketballTeams, out List<SoccerTeam> soccerTeams)
{
bastketballTeams = new List<BasketballTeam>();
soccerTeams = new List<SoccerTeam>();
//TODO
}
static void findAverages(List<BasketballTeam> basketballTeams, List<SoccerTeam> soccerTeams, out double basketballAverage, out double soccerAverage, out double averageBasketallGames, out double averageSoccerGames)
{
int pointSum = 0,
gameCountSum = 0,
playerCount = 0;
foreach (BasketballTeam team in basketballTeams)
{
for (int i = 0; i < team.PlayerCount; i++)
{
pointSum += team.GetPlayer(i).Points;
gameCountSum += team.GetPlayer(i).GameCount;
playerCount++;
}
}
basketballAverage = pointSum / playerCount;
averageBasketallGames = gameCountSum / playerCount;
gameCountSum = 0;
pointSum = 0;
playerCount = 0;
foreach (SoccerTeam team in soccerTeams)
{
for (int i = 0; i < team.PlayerCount; i++)
{
pointSum += team.GetPlayer(i).Points;
gameCountSum += team.GetPlayer(i).GameCount;
playerCount++;
}
}
soccerAverage = pointSum / playerCount;
averageSoccerGames = gameCountSum / playerCount;
}
static void findBTAPlayers(double basketballAverage, double soccerAverage, List<BasketballTeam> basketballTeams, List<SoccerTeam> soccerTeams, out List<BasketballPlayer> BTABasketballPlayers, out List<SoccerPlayer> BTASoccerPlayers)
{
BTABasketballPlayers = new List<BasketballPlayer>();
BTASoccerPlayers = new List<SoccerPlayer>();
foreach (BasketballTeam team in basketballTeams)
{
for (int i = 0; i < team.PlayerCount; i++)
{
BasketballPlayer player = team.GetPlayer(i);
if (player.Points > basketballAverage)
{
BTABasketballPlayers.Add(player);
}
}
}
foreach (SoccerTeam team in soccerTeams)
{
for (int i = 0; i < team.PlayerCount; i++)
{
SoccerPlayer player = team.GetPlayer(i);
if (player.Points > basketballAverage)
{
BTASoccerPlayers.Add(player);
}
}
}
}
}
}
namespace Uzduotis2
{
class SoccerPlayer : Player
{
public int YellowCardCount;
public SoccerPlayer(string firstName, string lastName, int gameCount, int yellowCardCount)
: base(firstName, lastName, gameCount)
{
YellowCardCount = yellowCardCount;
}
}
}
namespace Uzduotis2
{
class SoccerTeam : Team
{
private SoccerPlayer[] Players;
public int PlayerCount { get; private set; }
public SoccerTeam(string coach, string city, int gameCount, SoccerPlayer[] players, int playerCount)
: base(coach, city, gameCount, playerCount)
{
PlayerCount = playerCount;
Players = new SoccerPlayer[playerCount];
for (int i = 0; i < playerCount; i++)
{
Players[i] = players[i];
}
}
public SoccerPlayer GetPlayer(int index)
{
return Players[index];
}
public void AddPlayer(SoccerPlayer player)
{
Players[PlayerCount++] = player;
}
}
}
namespace Uzduotis2
{
abstract class Team
{
public string Coach { get; private set; }
public string City { get; private set; }
public int GameCount { get; private set; }
public Team(string coach, string city, int gameCount, int playerCount)
{
Coach = coach;
City = city;
GameCount = gameCount;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment