Let's sum this up into something I can understand.
Code:
Houses
- green
- 36 students
- X classes
- yellow
- 36 students
- Y classes
Theres 4 games where each house has to compete against eachother the 36 students from yellow house has to compete against the 36 students from green house, noone is allowed to compete in one game more than one time, noone is allowed to compete against another student in their class, and each game is decieded by a "best out of three" match.
If this is the lineout of your problem? Then you can actualy see the design in my small setup there.
As you can see theres two arrays containing 36 students classes, each student has their respective class assigned, the C++ classes would look something like this:
Code:
class game{
private:
std::string name;
bool play;
bool won;
/* not allowed to create a game without name */
game(void){};
public:
game(std::string n){name=n; played=false; won=false; };
void win_game(void){won=true; };
void play_game(void){play=true; }
bool win(void){return won; };
bool played(void){return play; };
}
class student{
private:
std::string name;
/* class is a keyword, so shortened */
std::string clss;
std::vector <game> games;
/* not allowed to create a student without name */
student(void){};
bool in_game(std::string g){
for(int i=0; i < games.size(); ++i)
if(games[i].get_name() == g)
return true;
return false;
};
public:
student(std::string n){name= n;};
void assign_class(std::string c){clss = c; };
void assign_game(std::string g){
if(!this->in_game(g))
games.push_back(g);
};
bool play_game(std::string g){
for(int i=0; i < games.size(); ++i)
if(games[i].get_name() == g)
{
games[i].play_game();
return true;
}
return false;
};
bool win_game(std::string g){
for(int i=0; i < games.size(); ++i)
if(games[i].get_name() == g)
{
games[i].win_game();
return true;
}
return false;
};
std::string get_name(void){return name; };
std::string get_class(void){return clss; };
void games_played(void){
for(int i=0; i < games.size(); ++i)
if(games[i].played())
std::cout << games[i].get_name() << std::endl;
};
void games_won(void){
for(int i=0; i < games.size(); ++i)
if(games[i].win())
std::cout << games[i].get_name() << std::endl;
};
}
class house{
private:
std::string name;
std::vector <student> students;
/* not allowed to create a house without name */
house(void){};
bool in_house(std::string s){
for(int i=0; i < students.size(); ++i)
if(students[i].get_name() == g)
return true;
return false;
};
public:
house(std::string n){name=n; };
void assing_student(student s){
if(!this->in_house(s.get_name()))
students.push_back(s);
};
std::string get_name(void){return name; };
}
I'm sure it can be further developed, or even designed in another manner.. This was just what I first thought of.