Help with VB project - Urgent

Programming, for all ages and all languages.
Post Reply
rwfromxenon

Help with VB project - Urgent

Post by rwfromxenon »

Hi, guys. I've got a VB assignment due in for college soon but I don't quite know how to implement it.
I have to write a program using Visual Basic (I'm using 6.0) that sorts a list of students into 2 teams. It then has to randomize a list of students who will play each other in a series of games. Students can't play anyone in the same team or the same class as them. They can only play each game once and they can't play the same person twice.

I've got half of the program working. I already have the list of students including which team and class they are in. The problem lies in the randomization of the lists. I think I have to give each student on either team an index number. I'd then use that number to randomize another which will correspond to a student on the other team. The problem is that I don't know how to do it. Once I've got that working it's easy. But I can't get any further until I solve it.

Sorry if I've not explained clearly. I need help with this as soon as possible, so any help you can give would be appreciated :)
AGKorson

Re:Help with VB project - Urgent

Post by AGKorson »

I'm not sure I understand your problem completely, but it sounds like your problem is more of an algorithm problem than a VB specific problem.

You mention that the students are assigned to teams, but then say that students in the same class can't play each other. Where did the 'class' restriction come from? How many classes are there? Can students from different classes be on the same team?

If you could clarify the relationship between students, teams, and classes, that would be helpful.

I'm also curious as to how you've approached the problem with respect to data structure (i.e, what kind of data types (objects(classes), user defined, integers, strings,...)

Using classes or UDTs would probably make it easier accomplish your task.

If you need help with VB specific issues like creating/using classes, UDTs, or VB specific syntax, I'd be glad to help with that.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Help with VB project - Urgent

Post by Solar »

I know this will probably not help you in your college assignment, but it's a practical approach I used once when the "rules" were much more complicated than you depicted: I made up a "fair" playing schedule manually, with numerical placeholders instead of player names. Then I made the players draw numbers from a hat, filling in their names in the schedule as we went. Organized as a big bottle party, we had a real blast as the schedule was "fleshed out" on a whiteboard over the course of the evening and it became clear who would be playing whom. ;-)

On a more college-oriented tangent, I as a OO programmer consider the design of the data structures to be the essential step in the design. Telling you exactly how to do it would spoil the learning experience for you, so you'd have the same problem next time you get an assignment.

A player's playing schedule is part of the player, just like his class or team number.
Every good solution is obvious once you've found it.
rwfromxenon

Re:Help with VB project - Urgent

Post by rwfromxenon »

Argh, after much thought I figured it out.
As Andrew inferred correctly, it WAS an algoritmic problem. Since there were only 4 games, 6 classes with 6 people in each class and 18 people in each team (36 people total), what I ended up doing was separating the teams into 2 lists, and moving the items in one of the lists down 4 places for each game. My lecturer told me that it didn't really need to be randomized so that made things a bit easier. Anyway, thanks for the help guys.

@Solar: I agree with what you say about learning yourself, and I wouldn't have asked had I not been so confused :P
Post Reply