Hey, I currently have to write a program that will simulate a tournament that takes place between a number of entrants. The details of this program are as follows -
Learning Outcomes
This addresses the following learning outcomes
• Be able to implement, compile, test and run Java programmes, comprising more than
one class, to address a particular software problem.
• Demonstrate the ability to employ various types of selection constructs in a Java pro- gram.
• Demonstrate the ability to employ repetition constructs in a Java program.
• Demonstrate the ability to use simple data structures like arrays in a Java program.
Requirements. Design, implement and test a tournament as described below. A tourna- ment is a (ordered) list of players. A player has a name and the number of matches won and lost (non-negative integers). Shown below is a tournament before any matches have been played so the number of matches won and lost is zero in each case. The number at the begin- ning of each line is their current position in the tournament. Initially this will be the order the players are input. The number of games played is calculated from sum of the number of games won and the number lost.
0: Susie: Played 0, Won 0, Lost 0 1: Abdul: Played 0, Won 0, Lost 0 2: Jean: Played 0, Won 0, Lost 0 3: Pete: Played 0, Won 0, Lost 0 4: Sara: Played 0, Won 0, Lost 0
A player (a challenger) is allowed to challenge another player (the opponent) who is above them in the list. To challenge a player the position of the challenger and the opponent are input. If the challenger wins, the challenger and the opponent swap positions. For example if Pete challenges Abdul (this is allowed as Abdul is above Pete in the tournament) and wins, Pete moves to position 1 and Abdul moves to position 3. The number of matches played, won and lost are incremented to reflect this. Pete has now played and won one match and Abdul has played and lost one match.
0: Susie: Played 0 Won 0 Lost 0
1: Pete: Played 1 Won 1 Lost 0
2: Jean: Played 0 Won 0 Lost 0
3: Abdul: Played 1 Won 0 Lost 1
4: Sara: Played 0 Won 0 Lost 0
1
Lab10
2 If Jean challenges Susie but Jean loses the order remains unchanged. Jean has now played
and lost one match and Susie has played and won one match.
0: Susie: Played 1 Won 1 Lost 0 1: Pete: Played 1 Won 1 Lost 0 2: Jean: Played 1 Won 0 Lost 1 3: Abdul: Played 1 Won 0 Lost 1 4: Sara: Played 0 Won 0 Lost 0
If Pete challenges Jean this is not allowed as Jean is below Pete in the tournament. Similarly a player isn’t allowed to challenge themselves. Initially the names of players should be entered by the user. To represent challenges, the position of the challenger and the opponent are input by the user (using a loop). Assume that the input of a negative challenger position means no more challenges are to be input. Otherwise, if a position is entered that doesn’t exist the user should be informed and allowed to re-enter this.
I have a few ideas of how best to proceed with this code but i'm not 100% sure. Does any one have any tips or hints that may be able to help? If so please get back to me.
Thanks, Mike