Archaeology Rocks is a global company that provides groups of people to perform excavations (archaeological digs) in all parts of the world. You are continuing your coding of the DIGS (Data Involving Groups Sent) system that the company uses to manage people sent on field trips.
PLEASE make a new directory in your latcs account for Assignment 3.
In Progress Check 2, you developed a utility class, Identity.java, that allowed the company to extract or update information on a person’s identity card. You will need a copy of that class in the directory where you develop Assignment 3 (or you can copy a sample solution with the following command when in your new directory):
cp /home/1st/csilib/cse1oof/Identity.java .
More classes needed by the DIGS system are developed in the following tasks.
Details kept on each person available to send on field trips include a name and an identity code (formatted as discussed in Progress Check 2). A boolean onDig indicates whether the person is currently on a field trip and a fieldDays array stores how many days the person has been on field trips in Europe, Asia and The Americas in the first, second and third elements of the array respectively.
Begin coding your Person class, providing attributes as indicated in the class diagram. Then provide the following functionality for the Person class:
name: Daniel Jackson code: M321A2CR onDig: true fields days in Europe: 99 Asia: 999 The Americas: 9999
Before continuing to Task 2, you should run some tests in a driver to verify that your Person class is correct.
A menu-based interactive driver program DIGSDriver.java and an array-based collection of persons in RockStaff.java have been partly coded.
See the end of this assignment for skeleton code in DIGSDriver.java and the array-based collection of Person objects in RockStaff.java. Instructions for copying the files from the csilib area are given.
Copy the files into the same directory as your Person and Identity classes, understand the code, compile and see how the menu works. The menu displays as follows and currently outputs messages that a selected option is not yet implemented.
********************
DIGS ROCKS
********************
S) Show all persons
E) Edit submenu
A) Add a person
R) Read from file
C) Choose a group
H) Handle field days
?) Relax
Q) Quit
********************
Please select:
This menu repeatedly displays after each (case-insensitive) user selection, until the user chooses ‘Q’ or ‘q’ to quit the program. Selecting ‘E’ or ‘e’ displays a submenu to make changes to a person’s identity code.
The RockStaff class is designed to contain an array of references to Person objects as one of its attributes. You may assume no more than 2000 people are on the DIGS system. Required functionality for this class includes a constructor (already coded). Write methods to:
In RockStaff.java
In DIGSDriver.java
You are required to add more functionality to the RockStaff class and then complete more of the DIGSDriver class.
In the RockStaff class write a method to do the following: Given an input file name as parameter, append people from the input file into the array. You may assume that the file exists and contains the details (or record) for each person in 4 lines; that is, name, code, whether they are “on a dig” or “available” and a line containing three integers separated by a space (indicating field days in Europe, Asia and The Americas). A sample input file follows (Note you can use this option any time during the program):
Daniel Jackson
M321A2CR
on a dig
99 999 9999
Indiana Jones
M339A0R
available
1000 867 28
Amy Pond
F246V1RCH
on a dig
50 100 34
Now in the DIGSDriver class implement menu option ‘R’: Option ‘R’ prompts the user for the name of the file and calls the appropriate method in the RockStaff class.
In the RockStaff class write a method to do the following: Given a String parameter corresponding to a person’s name, an integer parameter (value of 0, 1 or 2 corresponding to Europe, Asia or The Americas) and another integer parameter corresponding to the extra days to be added, update that person’s field days and set their onDig attribute to false. If the person does not exist, output an error message to screen. The method heading could be:
public void addDays(String name, int where, int days)
Hint: You may wish to write a search() helper method in RockStaff. It could return the index of the person or -1 if the person does not exist. The method heading could be:
private int search(String name)
Now in the DIGSDriver class implement menu option ‘H’: Option ‘H’ should prompt the user for the person’s name and whether the field trip was in Europe, Asia or The Americas and how many days should be added.
Optional Task 1:
Optional Task 2:
Menu option ‘?’ Design a two- dimensional board game to amuse the user during their lunch break. For example, a player could start in the top left hand corner of the board and proceed left to right along each row, until the bottom right-hand corner is reached. Certain board positions could be lucky or unlucky in some way. Display the board, player(s), and other information using characters output to screen, and redisplay the board after each move. Perhaps the ability to stop playing part way through the game (to return to work) would be useful (without saving the game state). On completion of the game, the user is returned to the main menu. Note Math.random( ) is a useful method for generating random numbers.