|
On D2L, submit
tournament.adb,
queues.adb,
stacks.adb.
You do not need need to submit the package-specifications
queues.ads,
stacks.ads.
Bring hardcopy by on Monday (you can put it under my door if I'm not around).
You are to write an Ada program simulating a tournament that is a series of last-person-standing contests. You will read in the player-descriptions (name, skill-level), and then print the tournament-results. The tournament proceeds as follows:
A match between two individuals is resolved by skill, with tie-breakers given here. The match-winner is the player with…
Input: Input is from stdin, with two successive lines of input for each player. The first line of input for a player contains the players name. You should trim this line, but it can contain embedded white space and other characters. The second line contains two positive integers: A skill level and an age. Skill levels will be in the range 1 .. 999 and age in the range 3 .. 99. There can be white space around any name or value. There can be any number of players (well, within memory limits). You may assume that the input is valid.
Since there is no limit on the name length you may wish to look at
The output of your program should consist of a header followed by the information for each player, in columns, with one line per player:
Players should be printed reverse order (i.e. the winner of the very first match gets printed last). Print one line per player (even if there are are only zero or one players).
UI detail: If copy/pasting the above, be sure to drag the mouse just slightly out of the box, so that your copying includes the final newline (after the 51).
Stacks and Queues:
You must implement a dynamic implementation of a queue and a stack,
using the
queues.ads
and
stacks.ads
package specifications.
Notice that these packages contain a procedure
Do not make any changes to these specification files. (I will use the originals, when I compile your program.)
As always: structure your program well, and make good use of language features.
Some class-notes, and a good set of incremental steps, about queues can be found here.
My own solution used a helper routine called
In the notes on Generic Child Packages the second example use a print routine as a parameter. This is similar to this assignment's generic stack and queue packages, which have a parameter for printing. (Of course, the actual code is different from this assignment, since the example uses arrays and child packages).
Notice that types
You might find it helpful to keep a count of the number of players, which you can use to control how many matches need to be played on each queue since each match moves one player off the queue.
If you want to work on your client program before you have your dynamic queue packages working (not advised), then you can implement and use the array implementations of (bounded) stacks and queues. If you do so, do not submit your array implementations.
This page licensed CC-BY 4.0 Ian Barland Page last generated | Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |