I am a java beginner and as a task I was given to implement a champions league second phase draws. The program that I am going to implement must contain the following classes:
Team – This class will contain the name of the team as well as the country of the
team and qualifying group
✔ Pot – This class will contain 8 instances of the class team
✔ DrawEngine – This class will contain the main draw strategy. In our case it will
contain the two instances of class Pot. It will be responsible to implement the rules
of the draw (country checking etc.)
✔ Draw – This class contains the two teams drawn against each other. Your
application should finally produce eight instances of this class.
The rules for the champions league game are the following:
Teams coming from the same country may not be picked up against each other.
Teams from the same group may not be drawn against each other.
I started implementing the Team class and I have done the following:
public class Team {
String name;
String country;
Double luckFactor;
Double strength;
Team TeamsInPot1 = new Team[8];
teamInPot1[0] = new Team ("Manchester United");
teamInPot1[1] = new Team ("Real Madrid");
teamInPot1[2] = new Team ("Liverpool");
teamInPot1[3] = new Team ("Milan");
teamInPot1[4] = new Team ("Inter");
teamInPot1[5] = new Team ("Birkirkara");
teamInPot1[6] = new Team ("Barcelona");
teamInPot1[7] = new Team ("Brussels");
teamInPot1[0].country = "England";
teamInPot1[1].country = "Germany";
teamInPot1[2].country = "England";
teamInPot1[3].country = "Italy";
teamInPot1[4].country = "Italy";
teamInPot1[5].country = "Malta";
teamInPot1[6].country = "Spain";
teamInPot1[7].country = "Belgium";
Team TeamsInPot2 = new Team[8];
teamInPot2[0] = new Team ("Chelsea");
teamInPot2[1] = new Team ("Juventus");
teamInPot2[2] = new Team ("Lisbona");
teamInPot2[3] = new Team ("Leeds");
teamInPot2[4] = new Team ("SKV ");
teamInPot2[5] = new Team ("Berlin ");
teamInPot2[6] = new Team ("Paris");
teamInPot2[7] = new Team ("Valletta");
teamInPot2[0].country = "England";
teamInPot2[1].country = "Italy";
teamInPot2[2].country = "Portugal";
teamInPot2[3].country = "England";
teamInPot2[4].country = "Austria";
teamInPot2[5].country = "Germany";
teamInPot2[6].country = "France";
teamInPot2[7].country = "Malta";
}
The problem now is that I dont know how am i going to randomly generate the countries and make them obey the rules that i gave i.e. no teams of the same countries are placed against each other.
any help would be very appreciated.
thanku