Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

connecting components with data?

MormengilMormengil Member Posts: 1
hi all :D I've got difficulty connecting data with components of borland c++ builder.. here's what I'm trying to do: you got a game, you choose play and you're redirected to a form with 5 flags of 5 national teams for instance. my problem is: what can I do to link 'user1' (the game is user1 vs user2) with the team 'brazil' for example when he clicks its flag? when you click the flag, you're then redirected to another form where you'll choose your squad. I'll have 11 comboboxes. my second problem: after I've linked user1 with team 'brazil' for example, how do I make the combobox down below only show the members of the squad who have GK as their position? the next 4 only CB or SB position etc..

here's my code:

#include
#include
#include
#include
#define MAX_TEAMS 2
#define MAX_PLAYERS 3

struct paixtes {char pname[15]; char position[3]; unsigned int power;};
typedef struct paixtes players;
struct omades {char tname[15]; players pl[MAX_PLAYERS];};
typedef struct omades teamz;
teamz teams[MAX_TEAMS];

void add_team(char *tname);
void add_player(char *pname, char *position, int power);

int main(void) {
int c, p=0;
add_team("Real Madrid");
add_team("FC Bayern Munich");
add_player("Rivaldo","SS",10);
add_player("Ronaldo","SS",10);
add_player("Romario","SS",10);
add_player("Robinho","SS",10);
add_player("Ricardo","SS",10);
add_player("Rinaudo","SS",10);
return 0;
}

void add_team(char *tname) {
unsigned short int c = 0;
for (c=0; c<=MAX_TEAMS; c++)
strcpy(teams[c].tname, tname); }

void add_player(char *tname, char *pname, char *position, int power) {
unsigned short int c, p = 0;
for (c=0; c<=MAX_TEAMS; c++)
for (p=0; p<=MAX_PLAYERS; p++) {
strcpy(teams[c].pl[p].pname, pname);
strcpy(teams[c].pl[p].position, position);
teams[c].pl[p].power = power; } }

the code is written in such a way that each time you time 3 players, the next 3 ones go to the second team etc..

to sum up: a friend told me I can't use main in such a program.. I hope that's not true :P if it's not, how do I link 'user1' with the team brazil for instance when he clicks its flag? and in the next form, how do I make the comboboxes choose ONLY the players from brazil with the positions I want? first combobox GK, next 4 positions CB or SB etc.. in the end the program is supposed to take all the powers from the 11 players chosen by user1 and user2 and give out a result by comparing the sum of powers of user1 to the one of user2. thanks in advance --let me also make clear I'm not a lazy person, I've been trying to get this done for quite a while now and I'm stuck with these two-three questions.. thanks in advance, I really appreciate all the help
Sign In or Register to comment.