קוד:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.IO;
namespace test
{
public class IncorrectTeamID : ApplicationException
{
public IncorrectTeamID(string message)
: base(message)
{
}
}
public class Game
{
int HostTeamID;
int GuestTeamID;
int HostGoals;
int GuestGoals;
public Game(int hostTeamId, int guestTeamID, int hostGoals, int guestGoals)
{
this.HostTeamID = hostTeamId;
this.GuestTeamID = guestTeamID;
this.HostGoals = hostGoals;
this.GuestGoals = guestGoals;
}
public int Host_Team_ID
{
get { return this.HostTeamID; }
}
public int Guest_Team_ID
{
get { return this.GuestTeamID; }
}
public int Host_Goals
{
get { return this.HostGoals; }
}
public int Guest_Goals
{
get { return this.GuestGoals; }
}
public override string ToString()
{
return "Host Team ID :" + HostTeamID + "Host Team Goals: " + HostGoals + "Guest Team ID: " + GuestTeamID + "Guest Team Goals: " + GuestGoals;
}
}
public abstract class Team : IComparable
{
int TeamID;
string TeamName;
int gameCount = 0;
Game[] GamesArray = new Game[50];
public Team(int teamID, string teamName)
{
if (teamID < 1 || teamID > 24)
{
throw new IncorrectTeamID("Team ID Should Be between 1 and 24: " + teamID);
}
this.TeamID = teamID;
this.TeamName = teamName;
}
public void AddGame(Game g)
{
GamesArray[gameCount] = g;
gameCount++;
}
public int Team_ID
{
get { return this.TeamID; }
}
public string Team_Name
{
get { return this.TeamName; }
}
public override string ToString()
{
return "Team ID: " + TeamID + " " + "Team Name: " + TeamName;
}
public int GameCount()
{
return this.gameCount;
}
public int GameCount(Team t2)
{
int count = 0;
for (int i = 0; i < GamesArray.Length; i++)
{
if ()
{
}
}
return count;
}
public int CompareTo(object obj)
{
throw new NotImplementedException();
}
}
class Program
{
static void Main(string[] args)
{
Team t1 = new Team(1, "a");
Team t2 = new Team(2, "b");
Team t3 = new Team(3, "c");
Team t4 = new Team(4, "d");
Game g1 = new Game(1, 2, 3, 1);
Game g2 = new Game(1, 2, 6, 4);
Game g3 = new Game(1, 2, 0, 4);
Game g4 = new Game(1, 2, 2, 2);
Game g5 = new Game(3, 4, 3, 6);
Game g6 = new Game(3, 1, 0, 0);
Console.WriteLine(t1.ToString());
Console.WriteLine(t2.ToString());
Console.WriteLine("ADD GAME");
t1.AddGame(g1);
t1.AddGame(g2);
t1.AddGame(g3);
t1.AddGame(g4);
int result = t1.GameCount(t2);
Console.WriteLine(result);
int g1_get = g1.Host_Goals;
int g2_get = g1.Guest_Goals;
Console.WriteLine(g1_get);
Console.WriteLine(g2_get);
Console.ReadLine();
}
}
}