Archaeology Rocks is a global company that provides groups of people to perform excavations (archaeological digs) in all parts of the world. The company has contracted you to write a small application to help manage the people sent on these field trips. Certain classes needed by this Data Involving Groups Sent (DIGS) system are developed in the following tasks.

Task 1a – An Identity Check Utility Class

Note: There may be better design decisions for this task but you are being asked to write a utility class for the purpose of practising class methods.) Each person associated with DIGS has an identity card with a chip that contains a personal information code, formatted as follows (all letters in uppercase):

F – female or M – male, three digit personnel number (digits 0 to 9 inclusive, repetition allowed), classification (possible allowed values of A, S or V), first aid level (possible allowed values of 0, 1 or 2), A driving licence list that contains between 1 and 3 characters inclusive, representing the vehicles the person can operate. There are 3 types of vehicle licences, a car licence (C), a bike riders licence (R), and a heavy vehicle licence (H). The list contains any combination of C, R and H where each letter occurs at most once. All people have at least one licence (and at most three).

The classification values have the following meaning:

  • A: Archaeologist
  • S: Student
  • V: Volunteer

The first aid level values have the following meaning:

  • 0: no first aid qualification
  • 1: level 1 first aid qualification
  • 2: level 2 first aid qualification

The DIGS system requires the ability to check that an identity code string is valid, and the ability to extract or update certain information contained in an identity code.

Write a utility class in a file called Identity.java that has separate class methods to perform the following functionality (assume all the String arguments are valid codes except for the method in Task 1b which is compulsory for CSE4OOF but is a bonus optional question for CSE1OOF – in this task you are asked to check that the code argument is valid).

  • A class method called getGender() that takes an identity code as argument and returns a character ‘M’ or ‘F’ indicating the gender of the person.
  • A class method called getIdNumber() that takes an identity code as argument and returns the personnel number as a string.
  • A class method called getClassification() that takes an identity code as argument and returns the appropriate classification value as a character A, S or V.
  • A class method called getFirstAidLevel() that takes an identity code as argument and returns a integer value of 0, 1 or 2 indicating the first aid qualification.
  • A class method called getLicences() that takes an identity code as argument and returns the licence list of the person as a string of the characters C, R and H.
  • A class method called updateFirstAidLevel() that takes an identity code and an integer as argument. The method should check that the integer is either 0, 1 or 2 and if so, update the first aid qualification and return the new identity code. If the integer is not an allowed value the original identity code is returned.
  • A class method called updateLicences() that takes an identity code and another string as argument. The other string contains the new set of licences (which you can assume is valid). Replace the licences in the argument identity code with the new licences and return this new identity code string.

Task 1b – compulsory for CSE4OOF but optional for CSE1OOF for bonus marks

  • A class method called checkIdentity() that takes an identity code as a String argument and returns a boolean value indicating whether the argument is a valid identity code (i.e. the right length and valid characters in each position).

Task 2 – Javadoc Comments

Having implemented the Identity utility class, add Javadoc style comments to any four methods only of this class.

Task 3 – Test Driver for the Identity utility class

In a file called IdentityTester.java write appropriate tests to check the functionality of your Identity utility class.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.