Question: i need UML class diagram please do diagram on computer /*************************Person.java**********************/ package person; // TODO: Auto-generated Javadoc /** * The Class Person. */ public class
i need UML class diagram please do diagram on computer
/*************************Person.java**********************/
package person;
// TODO: Auto-generated Javadoc /** * The Class Person. */ public class Person {
/** The id. */ private int id;
/** The first name. */ private String firstName;
/** The middle name. */ private String middleName;
/** The last name. */ private String lastName;
/** The email. */ private String email;
/** The ssn. */ private String ssn;
/** The age. */ private int age;
/** The max age. */ public static int maxAge = 0;
/** * Instantiates a new person. */ public Person() {
this.id = 0; this.firstName = ""; this.middleName = ""; this.lastName = ""; this.email = ""; this.ssn = ""; this.age = 0; }
/** * Instantiates a new person. * * @param id the id * @param firstName the first name * @param middleName the middle name * @param lastName the last name * @param email the email * @param ssn the ssn * @param age the age */ public Person(int id, String firstName, String middleName, String lastName, String email, String ssn, int age) { super(); this.id = id; this.firstName = firstName; this.middleName = middleName; this.lastName = lastName; this.email = email; this.ssn = ssn; if (age > maxAge) { maxAge = age; } this.age = age; }
/** * Gets the first name. * * @return the first name */ public String getFirstName() { return firstName; }
/** * Sets the first name. * * @param firstName the new first name */ public void setFirstName(String firstName) { this.firstName = firstName; }
/** * Gets the middle name. * * @return the middle name */ public String getMiddleName() { return middleName; }
/** * Sets the middle name. * * @param middleName the new middle name */ public void setMiddleName(String middleName) { this.middleName = middleName; }
/** * Gets the last name. * * @return the last name */ public String getLastName() { return lastName; }
/** * Sets the last name. * * @param lastName the new last name */ public void setLastName(String lastName) { this.lastName = lastName; }
/** * Gets the email. * * @return the email */ public String getEmail() { return email; }
/** * Sets the email. * * @param email the new email */ public void setEmail(String email) { this.email = email; }
/** * Gets the ssn. * * @return the ssn */ public String getSsn() { return ssn; }
/** * Sets the ssn. * * @param ssn the new ssn */ public void setSsn(String ssn) { this.ssn = ssn; }
/** * Gets the age. * * @return the age */ public int getAge() { return age; }
/** * Sets the age. * * @param age the new age */ public void setAge(int age) { if (age > maxAge) { maxAge = age; } this.age = age; }
/** * Gets the id. * * @return the id */ public int getId() { return id; }
/* * (non-Javadoc) * * @see java.lang.Object#toString() */ @Override public String toString() { return firstName + " " + middleName + " " + lastName; }
/** * Gets the email domain. * * @return the email domain */ public String getEmailDomain() {
return "@g m ail. c om ";//rearrange this }
/** * Gets the last 4 SSN. * * @return the last 4 SSN */ public String getLast4SSN() {
return ssn.substring(ssn.length() - 4, ssn.length()); }
/** * Valid age. * * @param testAge the test age * @return true, if successful */ public static boolean validAge(String testAge) {
int age = Integer.parseInt(testAge);
if (age > 16 && age < 120) { if (age > 100) {
System.out.println("Person age is above 100"); } return true; } else {
return false; } }
/** * Valid email. * * @param testEmail the test email * @return true, if successful */ public static boolean validEmail(String testEmail) {
String validator = "[A-Z]+[a-zA-Z_]+@\b([a-zA-Z]+.){2}\b?.[a-zA-Z]+"; if (testEmail.matches(validator)) {
return true; } else {
return false; } }
/** * Valid SSN. * * @param testSSN the test SSN * @return true, if successful */ public static boolean validSSN(String testSSN) { /* * ^\\d{3}: Starts with three numeric digits. [- ]?: Followed by an optional "-" * \\d{2}: Two numeric digits after the optional "-" [- ]?: May contain an * optional second "-" character. \\d{4}: ends with four numeric digits. */ String validator = "^\\d{3}[- ]?\\d{2}[- ]?\\d{4}$"; if (testSSN.matches(validator)) {
return true; } else {
return false; } }
} /*********************Driver.java*********************/
package person;
import java.util.HashMap; import java.util.Scanner;
/** * The Class Driver. */ public class Driver {
/** * The main method. * * @param args the arguments */ public static void main(String[] args) {
HashMap
System.out.println("Enter person's first name"); String firstName = scan.nextLine(); System.out.println("Enter person's middle name"); String middleName = scan.nextLine(); System.out.println("Enter person's last name"); String lastName = scan.nextLine(); System.out.println("Enter person's email address"); String testEmail = scan.nextLine(); System.out.println("Enter person's SSN in ###-##-#### format"); String testSSN = scan.nextLine(); System.out.println("Enter person's age"); String testAge = scan.nextLine(); int age = 0; String email = null; String ssn = null; if (Person.validAge(testAge)) {
age = Integer.parseInt(testAge); } if (Person.validEmail(testEmail)) {
email = testEmail; } if (Person.validSSN(testSSN)) {
ssn = testSSN; }
hm.put(103, new Person(103, firstName, middleName, lastName, email, ssn, age));
for (int key : hm.keySet()) { String ageFlag = ""; if(hm.get(key).getAge()==Person.maxAge) { ageFlag = "Oldest"; } else { ageFlag = "Not oldest"; } System.out.println(hm.get(key).toString()+" "+hm.get(key).getEmail()+" "+hm.get(key).getLast4SSN()+" "+ageFlag); System.out.println(); }
} }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
