Introduction to Programming Computer Programming I XXXXXXXXXXInstructor: Greg ShawPRIVATE COP 2210 Programming Assignment #9 (The ArrayList Class) I. Problem Statement The following story is told...

Everything is in the assignment doc.


Introduction to Programming Computer Programming I Instructor: Greg ShawPRIVATE COP 2210 Programming Assignment #9 (The ArrayList Class) 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 · 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 call the methods that add men and print the report. 4. Output will be a series of reports --- one report for each of the 20 weeks. 5. Output should be written to a file. 6. Each weekly report should begin with an appropriate heading, including the week number. 7. 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 8. Once a regiment has gone to the front, it should not appear in any of the subsequent reports. · To earn credit, your Army class must use a generic ArrayList-of-Regiment – not an array - as its only data structure III. Date dueDate = new Date(12,3,2019) ; (Tuesday, December 3rd) · Assignments will be accepted without late penalty until 12:30 on Thursday, 12/5 · Assignments will not be accepted after 12:30 on Thursday, 12/5 IV. High-Level Algorithm for the Assignment · Create the regiments and add then to the army · For each week of the simulation, do: · Add men to each remaining regiment · Find the largest regiment · Print the weekly report V. What to Upload to Canvas (The Usual) 1. A zip file containing your NetBeans project folder and the output 2. An empty Word doc to receive feedback VI. Hints The Army class method that finds the largest regiment should be a private “utility” method, called only by Army method printReport and not by client code. · Use Bank method getMaximum for guidance. That method returns the BankAccount object with the largest balance, but your method must return the index of the Regiment with the most men · See also the ArrayListIntro class which shows how to find a maximum and the index of the object containing it If we haven’t covered input files by the time this assignment is given do not let that keep you from starting! Write a temporary test class that reads the data for the first 6 or 7 regiments from the keyboard. That will let you write and test the entire program. Then, modify the input loop in the test class so that it reads from the file. Naturally, no changes will have to be made anywhere in your Regiment and Army classes · BankTester.java shows how to read data from the keyboard until eof, create objects, and add them to a list · BankTester2.java does the same, but the data are read from a file 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
Dec 04, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here