Vous êtes sur la page 1sur 3

Computer Programming I

COP 2210

Instructor: Greg Shaw

Programming Assignment #8

(ArrayLists)

I. Problem Statement
The following story is told about the Russian army at the time of
the Russo-Japanese War:
It seems that 20 regiments were in a continuous process of
formation. The first had 1000 men, the second had 950, the third
900, and so on down to the twentieth regiment, which garrisoned
only 50.
During each week, 100 men were added to each regiment,
and at week's end, the largest regiment was sent off to the front.
Apparently, the commander of the 5th regiment was a wonderful chess
player.
To delay his eventual trip to the front, the General of
the Army (who happened to be his chess partner) sent him only
thirty new recruits each week (instead of 100).
Write a Java program that tells which regiment is sent to the front
each week, shows the status of the remaining regiments, and
determines exactly how long it takes for the chess-playing
commander to go to the front.

II. Specifications
1. Create a class to represent a regiment. Each regiment knows its
regiment number, name, and strength (number of men).
2. Create another class to represent an army (an army is a
collection of regiments).
Your army class will feature
separate methods to do each of the following:

add a regiment to the list


update the list (i.e., add new men to each regiment)
find the largest regiment
print a report

3. Your test class will read the regiment number and name for each
regiment from a data file, until eof, compute the number of
initial recruits for the regiment, create a Regiment object,
and add it to the list.
Then, for each week of the
simulation, it will then call the methods that update the list
and print the report.

4. Output will be a series of reports --- one report for each of the
20 weeks.
5. Each weekly report should begin
including the week number.

with

an

appropriate

heading,

6. The report should state which regiment is being shipped out that
week, and data on the remaining regiments (i.e., those which
have not yet gone to the front) should be in column form,
neatly aligned, with headings.
For each remaining regiment
print the regiment number, name, and the current strength of
the regiment.

Remember that once a regiment has gone to the front, it


will not appear in any of the subsequent reports.

III. Due Date:

Thursday, December 4th

This assignment will be accepted without late penalty


until Tuesday, December 9th at 11:59 PM. This is
because the 11/27 labs were cancelled for Thanksgiving.
The assignment will NOT be accepted at any time AFTER
11:59 PM on December 9th.

A high-level algorithm for this assignment will be discussed in class

Vous aimerez peut-être aussi