Random Seats (4)
- Extend your previous exercise
so that your program is flexible enough to handle lists with other
sizes. You may test your program with
students-80.txt and
seats-80.txt.
- Bonus: If your program can handle the case when the total number of
students and the total number of seats do not match, you should
emphasize this when you submit the homework.
- Case 1: There are less students than seats.
This is easy. Just stop when there is no more student to be
printed out.
- Case 2: There are more students than seats.
If your program simply stops printing when it runs out of seats,
the user may never notice that he/she supplies insufficient seats.
Therefore, a better design is to re-use the seat arrangement in the last
row. For example, if you totally have 26 students, but the seats file
accidentally to contain only
4
5
6
Then a solution is that the program prints out students as if the seats
arrangment is 4,5,6,6,6.