I need help with this java program that uses arrays. I have the basic structure
ID: 3621704 • Letter: I
Question
I need help with this java program that uses arrays. I have the basic structure and some of it figured out, here is the program description:A Java program to create tournament pairings is to be created. The team names along with their wins should be stored in an array of objects. For this assignment the data will be obtained from a text file arranged in descending order by number of wins. The data for each team should be read from the input file. An object for that team should be created and then the object reference variable value should be stored in the present array element. After all data is read from the file and stored in the array, the pairings can be made.
To create the pairings, the first team in the array (the team with the best record) is matched with the last team in the array (the team with the worst record) to form the first game of the tournament. The process is repeated, matching the team with the next best record with the team with the next worst record to form the second game. The process continues until all teams have been paired. The number of teams to be paired will always be an even power of two. For example: the input would be 4, 8, 16, 32 or 64 teams for testing. The maximum number of teams is 64.
A driver class and a class to create the team object should be written. An array of objects ordered by team wins should be loaded as the input data is received, and then the pairings can be made as described above. The driver class should be named Tournament. The input data from will come from a text file named Teams.txt.
There can be varying numbers of teams entering the tournament, i.e. 4, 8, 16, 32 or 64; therefore the sample input data will vary for testing purposes.
Output: Output is to consist of an ordered list of the original teams along with their number of wins and the first round pairings created in the class. Output can be formatted as you wish.
Team pairings:
Sample Output:
Game 1: UNCC vs. UNC
Game 2: NCSU vs. UGA
Game 3: GT vs. UVA
Game 4: USC vs. GSU
Here is the basic structure of the program
create a class Team that holds the name of the team, the amount of wins for the team. have methods to get the name and the amount of wins. Also a method that increments the number of wins and have a constructor that takes the name and the amount of wins. Also have a no argument constructor so you can create an array of Teams.
create a driver class.
In the main method, get the input from the user and ask the user how many teams there are before getting any info about the teams.
Then create an array for all of the teams.
Team alllTeams = new Team[<the number of teams>];
Then create a for loop using the number of teams.
for (int i = 0; i < <the number of teams>; i++)
{
// get the name of the team.
// get the number of wins.
// create a new Team with this information.
// put the team in the array at position 1.
allTeams[i] = new Team(<name>, <number of wins>);
}
then sort the array according to the number of wins. Use the method in the Team class that says how many wins.
the output of the games like :
int gameNumber = 1;
for (int i = 0; j = allTeams.length - 1; i < j; i++, j--)
{
System.out.println("Game " + gameNumber + ": " + allTeams[ i ].getName() + " vs" + allTeams[ j ].getName());
gameNumber++;
}