/** * Write a description of class Person here. * @author (your name) * @version (a version number or a date) */ public class Person { // the person's full name private String name; // the personal ID private String id; /** * Constructor for objects of class Person * @param fullName name of this person * @param personID ID of this person */ public Person(String fullName, String personID) { // initialise instance variables name = fullName; id = personID; } /** * Return the full name of this person. * @return name of person */ public String getName() { return name; } /** * Set a new name for this person. * @param replacementName new name for this person */ public void changeName(String replacementName) { name = replacementName; } /** * Return the ID of this person. * @return returns the ID of this person */ public String getPersonID() { return id; } /** * Change personal ID * @param id new personal ID */ public void setPersonID(String id) { this.id = id; } /** * Return the login name of this person. The login name is a combination * of the first four characters of the person's name and the first three * characters of the person's ID number. * @return returns a string with this persons log-in ID */ public String getLoginName() { if(name.length() < 5) { System.out.println("Your name is too short. Your name needs to be at least 4 characters long."); return null; } else if(id.length() < 4) { System.out.println("Your ID is too short. It needs to be at least 3 characters long."); return null; } else { return name.substring(0,4) + id.substring(0,3); } } /** * Print the person's name and ID to the terminal. */ public void print() { System.out.println("Full name: " + name + ", personal ID: " + id); } }