I received the following test as a screening step to a potential Software Engineer position. I thought it was pretty good compared to the type and nature of screenings you usually get in the Tampa Bay market.
Here it goes:
Implement the missing class without modifying the provided classes.
The correct output should be:
Local Boys = 6 (Home)
Tourists = 0 (Away)
using System;
namespace Test {
public class FootballTeam : Team {
public FootballTeam(string name, FieldAdvantage side)
: base(name, side) {
}
public override int NumPlayers {
get {
return 11;
}
}
public void Touchdown() {
Score += 6;
}
}
public class Game {
public FootballTeam Home = new FootballTeam("Local Boys", Team.FieldAdvantage.Home);
public FootballTeam Away = new FootballTeam("Tourists", Team.FieldAdvantage.Away);
public static void Main() {
Game game = new Game();
Referee referee = new Referee(game);
game.Home.Touchdown();
game.Away.Touchdown();
game.Home.Score += 100;
Console.WriteLine("{0} = {1} ({2})", game.Home, game.Home.Score, game.Home.Side.ToString());
Console.WriteLine("{0} = {1} ({2})", game.Away, game.Away.Score, game.Away.Side.ToString());
}
}
public class Referee {
public Referee(Game game) {
game.Home.ScoreChange += new Team.ScoreChangeEventHandler(OnScoreChange);
game.Away.ScoreChange += new Team.ScoreChangeEventHandler(OnScoreChange);
}
private void OnScoreChange(Team.FieldAdvantage side, int newScore, ref bool overrule) {
if ((side == Team.FieldAdvantage.Away) || (newScore > 100))
overrule = true;
}
}
}
Advertisement