Jose Castellanos

Greenhorn
+ Follow
since Nov 13, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jose Castellanos

Hey everyone,

I have written a class for my programming assignment. When I run the test class it shows all of the regiments, their initial values, and the first report. However, the if statement at the bottom of the test class isn't working how I want it to. I want it to make more reports until there are no regiments left. Here are the specifications for the assignment.

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 with an appropriate heading, including the week number.


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.

Here is the Regiment and Army class:




Here is the Test class:


Here are the contents of the text file that was used as input:
1 Aardvarks
2 Begonias
3 Chrysanthemums
4 Dhalias
5 Elephants
6 Ferrets
7 GilaMonsters
8 Hyraxes
9 Ibex
10 Jackyls
11 KimodoDragons
12 Lemurs
13 Marigolds
14 Nonames
15 Opossums
16 Porcupines
17 Quahogs
18 Rhododendrons
19 Swordfish
20 Tapirs

The if statement at the end of the test class only works for one update. I want it to continue to show reports up until the last regiment is left. Any help would be greatly appreciated and thank you so much for your time!
7 years ago
This is a method within the speed dating class.

This is a part of the test class.

I need help with printing out how many days are in between the two dates that the user inputs.
7 years ago