Further Programming in Java SOE1 - Code
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Further Programming in Java
SOE1 - Code
20% of final grade
Instructions Please ensure you: · complete all of the code detailed in this document · submit your coursework on the date and time shown. There are penalties for late submission. · Submit your program completed in REPL only. · Submit using the URL of your REPL in SpeedGrader in Canvas only. · Submission by any other means will not be marked! |
Declaration of originality By submitting this work, I declare that: · This assignment is my own original work, except where I have appropriately cited the original source. · I have not sought help from anyone else, nor have I allowed my work to be copied. · I have not submitted this work as a summative assessment for any other module. · I will participate in academic integrity processes, including any online interviews by video conference, as required to confirm the submitted work is my own. · I understand that it is my responsibility to check that the folder and files I submit are readable, will compile and run using a Main class and method and fully complete. |
Lateness Policy The following penalty scale will apply for late submission: Up to 24 hours late Work submitted in this category will be considered late but will be accepted with a deduction of 10 percentage points (not 10%) of the overall mark. Deductions cannot reduce the mark beyond the progression thresholds which are as follows: IY1 = 40% This will, in some instances, mean no reduction can be made for lateness. Penalties are not applied to failed work. More than 24 hours late The work will not be accepted for marking. The work will be awarded a zero mark (0%) except where exceptional circumstances evidence is accepted (see Sussex ISC Exceptional Circumstances Policy) or reasonable adjustments (see Sussex ISC Reasonable Adjustments Policy) have been made. This will be presented at the Internal Assessment Board. NB: You need to ask for exceptional circumstance / reasonable adjustments well before the deadline. |
Register
This code will also form the base for SOE2 so it is essential you complete this assessment.
The program is a simple registration system stored using a HashMap. The key in the HashMap is the students last name, the data is an instance of the Student class.
Instructions
Student Class
Complete the Student class. Define Setters and Getters for all of the fields.
Add a toString method to the class that returns the following String as a CSV
0001,SMITH,Jane,10/02/2000,BN2 7BB
The items in the String above in order are:
the registration number padded left to a size of 4
· lastName
· firstName
· dateOfBirth
· postCode
import java.io.Serializable;
public class Student implements Person, Serializable {
private int registrationNumber;
private String lastName;
private String firstName;
private String dateOfBirth;
private String postCode;
}
StudentRegister Class
Complete the following methods in the Register class
public class StudentRegister implements Register, Serializable {
private HashMap<String, Student> studentRegister;
private final String DATA_FILE = "resources/register.ser";
public StudentRegister() {
studentRegister = new HashMap<>();
}
public boolean isValidName(String name)
Complete the method to check if name is valid - only alphabetic chars are allowed.
Print out a detailed error message if the method finds any problems in the String.
Return true if the String is OK, false if not OK.
public boolean isValidDate(String dateStr)
Complete the method to check dateStr represents the standard UK date format dd/mm/yyyy
Print out a detailed error message if the method finds any problems in the String.
Return true if the String is OK, false if not OK.
public boolean isValidPostCode(String postCode)
Complete the method to check if postCode represents a valid UK postcode. Format rules are:
· Starts with 1 or 2 characters A to Z
· Followed by a single digit
· Followed by an optional Single digit
· Followed by 1 character A to Z
· Followed by a space
· Followed by a single digit
· Followed by 2 characters A to Z
Print out a detailed error message if the method finds any problems in the String.
Return true if the String is OK, false if not OK.
public Integer addStudent(String studentStr)
Complete the method to add a student to the register using a single formatted CSV String studentStr to add the student.
You need to use the methods above to check if each part of the String is valid.
As this represents a new Student being added to the system calculate the registrationNumber using the number of items in the list once the Student has been added.
Check is the key (lastName) is already in the studentRegister. If it is give a warning message and do not add it.
Method returns the registrationNumber or null if the student was not added to the register.
public void printRegister()
Complete the method to print the contents of the studentRegister. Only print the values in the HashMap
These latter two methods are complete and do not need to be changed
public void readRegisterFile() {
studentRegister = FileIO.readSerialDataFromFile(DATA_FILE);
}
public void writeRegisterFile() {
FileIO.writeSerialDataToFile(DATA_FILE, studentRegister);
}
}
Main Code
public class Main {
public static void main(String[] args) {
StudentRegister studentRegister = new StudentRegister();
studentRegister.readRegisterFile();
studentRegister.addStudent("DOE,John,10/02/2001,BN1 7AT");
studentRegister.addStudent("SMITH,Sarah,6/7/2002,BN2 6WV");
studentRegister.addStudent("BROWN,Alice,12/12/1999,BN3 9TT");
studentRegister.addStudent("BROWN,Simon,16/3/1998,BN41 8TZZ");
studentRegister.addStudent("ARCHER,Simon,40/13/200,BN41 8TZZ");
studentRegister.addStudent("WALKER,George,10/4/1999,A1 8T");
studentRegister.printRegister();
studentRegister.writeRegisterFile();
}
}
Code is complete and has test data
2022-07-14