submit itec320-01 competition.adb queue_pkg.adb stack_pkg.adb
You are to write an Ada program that simulates a double elimination contest. Your program will input a list of players, each of whom has a name and an integer skill level. (More detail on the input format is given below.) After all players have been input, pairs of players are repeatedly formed and the members of a pair play a match against each other. As described below, the skill level (and perhaps some other information) determines who wins the match. Players are eliminated from the competition when they have two losses.
The sequence of play is as follows:
Players stand in lines until it is time for a match. Three lines are needed for different types of players: those with no losses, those with one loss, and those with 2 losses (ie those who have been eliminated). The players form the line of no losses as they arrive at the contest (ie the order of this line will initially be the same as the order of the input data). When match time comes, the first two players in the appropriate line get out of line and play a match. The winner goes to the back of the same line, and the loser goes to the back of the line containing players with the appropriate number of losses.
Players in any line play in order. In other words, the first two play, then the second two play, then the third two play, and so on, until only one player remains in that line.
The output of your program should consist of the following information for each player, in columns with one line per player:
In the output, the list of players should be in the REVERSE of the order in which they were eliminated. In other words, the winner should be first, followed by the player who the winner most recently beat, and so on with the player who was eliminated first at the end of the output. Here is a sample run.
Person890123456789 500 Person2 400 Person3 300 Person4 200 Person5 100
Name Number Skill Wins Losses Person890123456789 1 500 4 0 Person2 2 400 2 2 Person3 3 300 2 2 Person5 5 100 0 2 Person4 4 200 0 2
Input comes from standard input and consists of one line of input for each player. Each line of the input consists of the name in the first 20 columns and the skill level beginning in column 21. Your program should produce meaningful output if there are zero, one, or two players. (Don't forget that two players should have contests, until one has two losses.) You may assume that the input is valid.
A player's skill level will be represented by an integer. In a match between two players, the player with the largest skill level wins. If two players have the same skill level, the player with the largest number of wins will win. If two players have the same skill level and number of wins, the one with the fewest number of losses will win. IF two players have the same skill level and number of wins and losses, then the one who arrives first wins (ie the winner is the player who is first in the input).
You must implement a dynamic implementation of a stack and a queue,
[Note: If you want to work on your client program before you have your dynamic queue packages working, then you can implement and use the array implementations of stacks and queues. However, if you do this, do NOT submit the array implementations.]
It is important that you do not make any changes to these specification files
Your program should be called
You do not need
to raise any exceptions in your program.
s: String(1 .. 20);. Make sure that you don't have extra blanks at the end of the input lines and that you create your input file on the same system that you are executing your program.
showstaticin the URL for this page.
Extra credit: For 10 points extra credit, you can write your client using pointers. In some ways, using pointers makes the client a bit more complex to write; however, in other ways, using pointers actually simplifies the program.
You will want to structure your program well and make good use of language features. As always, be sure to use good indentation, descriptive constant, variable, type, function, procedure, and package names. Use named constants when appropriate. Also use good commenting style, remembering that the first thing in any program file should be a comment that gives a brief overview of what the file contains (and should do). You might find these commenting guidelines helpful.When testing, be sure to use lots of different examples. You can either supply test data at the keyboard (remembering to end the input with a ^D at the beginning of a line), or by feeding the contents of a file to it (e.g. calc < test_data) where the use of the UNIX redirection symbol < causes the contents of the file test_data to be feed into the program as if they had been typed in from the keyboard.
When debugging programs, run-time exceptions are a common occurrence. One way to find the line at which an exception occurs is to place put statements in your program so you can follow it's execution. Another way is to use the gdb debugger (ie gnu debugger): these instructions show you how. Note that you can also use gvd (the gnu visual debugger) to debug your program and find the source of an exception as well as other information.
Use the submit command to turn your program in for grading. You may submit as many times as you like, but since only the last submission is kept, if the last one is late, then your assignment is late. Always remember to use the -ls option of submit to check that your submission was received. To submit your work you can use the command at page top.