submit
itec320-01 compete.adb queues.adb stacks.adb
Last modified:
Updates:
You should now use this URL for the assignment checker: itec-noki01. The old one will disappear.
You are to write an Ada program simulating a double-elimination tournament. You will read in the player-descriptions (name, skill-level, age), and then print the tournament-results. The tournament proceeds as follows:
Match rules:
Input: Input is from standard input, 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 postive 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 Ada.Strings.Unbounded. This package contains a procedure Trim which uses a value for Side which is of type Trim_End, defined in package Ada.Strings. You can use Ada.Text_IO.Unbounded_IO.Get_Line to input an Unbounded_String. You may need to use procedure Ada.Text_IO.Skip_Line when processing the input.
Output: 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:
the first person to join the all-done line is printed last first,
and the last person to join that line (ie the person who doesn't have two losses) is printed first last.
Print one line per player (even if there are are only zero or one players).
Sample run: With the input shown below
Person uno 500 55 Player dos 400 54 Senorita tres 300 53 Chap cuatro 200 52 Person cinco 100 51
Expected output:
Stacks and Queues:
You must implement a dynamic implementation of a queue and a stack,
using these
queue and
stack
package specifications.
Notice that these packages contain a procedure print
that prints
the current stack and queue. You can use this for debugging, and perhaps
for printing your output. Notice that the packages have a parameter
for a routine for printing an item of type ItemType
.
(Why?)
It is important that you do not make any changes to these specification files.
Notes:You must create an access type for players so that you can use pointers to players on your lines.
Dr. Barland's notes on writing the queue package.
You will of course want to structure your program well and make good use of language features.
In the notes on Generic Child Packages the second generic package 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 example is different from this assignment since the example uses arrays and child packages).
Notice that types stack
and queue
are limited
types, which means that a variable of type stack
or queue
can't be assigned (ie be on the left of an assignment statement) in the client.
You might find it helpful to keep a count of the number of players; you can use this count 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, then you can implement and use the array implementations of stacks and queues. However, if you do this, do NOT submit your array implementations.