G22.2110-001 Programming Languages
Homework 7 -- Due July 21
For this homework you will write – you guessed it
electronic voting system.
You will be using Ada
again, and you can modify the system you wrote for assignment 2. This
system will be multitasking and will use exceptions to handle problems.
- Create 1 server task, which maintains
a count of all of the votes and enforces the rules against voting
twice, etc. The server should accept votes from a client, and create a
separate task to handle each vote. You must ensure that the tasks
cannot interfere with each other when updating shared data, such as
- Create at least 3 client processes
each of which sends a stream of votes to the server. You can read the
vote data from files, or embed it in the program (each client should
use different data.)
- Your program should handle problems
such as a candidate index out of range by throwing an exception and
handling it appropriately.
- Your server should generate a trace or
log showing what it is doing, e.g., “recording a vote for candidate X
by voter Y from client task N”. Be sure to record messages indicating
- Your main program should wait until
all of the tasks have finished, and then print the total number of
votes from each client, the total number of votes for each candidate,
and the total number of votes rejected. (The server totals should match
the client totals, if they don't you probably have a race condition).
You don’t have to worry about displaying a list of
candidates for this assignment, since the voting will be done
your client tasks.
You must turn in the following:
- A listing of your source code
- A trace of running your program that
- Successful votes
- Handling of a candidate index out of
- Handling of a voter attempting to
vote twice from different clients.
- An email, to Zilin,
containing your source code, any data files you used, and a