Question
I need help with the flowchart, pseudocode, and UML diagram. Person.java package studentDetails; public class Person { private String name; private String address; private String
I need help with the flowchart, pseudocode, and UML diagram.
Person.java
package studentDetails;
public class Person {
private String name;
private String address;
private String phoneNumber;
private String emailAddress;
/**
* Constructor with parameter @param personData
*/
public Person(String[] personData) {
this.name = personData[0];
this.address = personData[1];
this.phoneNumber = personData[2];
this.emailAddress = personData[3];
}
/*
* Default constructor
*/
public Person() {
}
// Getter and setter methods for Person fields
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getEmailAddress() {
return emailAddress;
}
public void setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
// Returns String with details of Address, Phone number and email address
@Override
public String toString() {
return " Address: " + address + " Phone Number " + phoneNumber + " Email Address: " + emailAddress;
}
}
Student.java
package studentDetails;
public class Student extends Person {
//Class status variable
private final String CLASS_STATUS;
public String getCLASS_STATUS() {
return CLASS_STATUS;
}
/*
* Constructor with parameters
*/
public Student(String CLASS_STATUS, String[] personData){
super(personData);
this.CLASS_STATUS = CLASS_STATUS;
}
//toString method returns student details in the required format
@Override
public String toString() {
return "Student: "+ getName()+" Status "+ CLASS_STATUS+super.toString();
}
}
Employee.java
package studentDetails;
public class Employee extends Person {
private int officeNumber;
private int salary;
private MyDate dateHired;
/*
* Constructor with parameters
*/
public Employee(String[] personData, int officeNumber, int salary, MyDate dateHired) {
super(personData);
this.officeNumber = officeNumber;
this.salary = salary;
this.dateHired = dateHired;
}
public Employee() {
}
/*
* Getter and Setter methods for Employee fields
*/
public int getOfficeNumber() {
return officeNumber;
}
public void setOfficeNumber(int officeNumber) {
this.officeNumber = officeNumber;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
public MyDate getDateHired() {
return dateHired;
}
public void setDateHired(MyDate dateHired) {
this.dateHired = dateHired;
}
@Override
public String toString() {
return " Salary: $" + getSalary() + " Date Hired: " + getDateHired().getDate() + super.toString();
}
}
MyDate.java
package studentDetails;
public class MyDate {
private String date;
public MyDate(String date) {
this.date = date;
}
public String getDate() {
return date;
}
}
Faculty.java
package studentDetails;
public class Faculty extends Employee {
String officeHours;
String rank;
public Faculty(String[] personData, int officeNumber, int salary, MyDate dateHired, String officeHours,
String rank) {
super(personData, officeNumber, salary, dateHired);
this.officeHours = officeHours;
this.rank=rank;
}
public String getOfficeHours() {
return officeHours;
}
public void setOfficeHours(String officeHours) {
this.officeHours = officeHours;
}
public String getRank() {
return rank;
}
public void setRank(String rank) {
this.rank = rank;
}
@Override
public String toString() {
return " Faculty: "+getName()+ " Rank: "+rank+" Office hours: "+officeHours+" Office: "+getOfficeNumber() +super.toString();
}
}
Staff.java
package studentDetails;
public class Staff extends Employee {
String title;
public Staff(String[] personData, int officeNumber, int salary, MyDate dateHired, String title) {
super(personData, officeNumber, salary, dateHired);
this.title = title;
}
public Staff(String title){
this.title=title;
}
@Override
public String toString() {
return " Staff: "+getName()+" Title: "+ title+ super.toString();
}
}
Driver.java
package studentDetails;
import java.util.Scanner;
public class Driver {
public static String[] personDetails=new String[4];
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the Choice:");
System.out.println("1) To create a student");
System.out.println("2) To create a employee");
System.out.print("Choice: ");
while (scanner.hasNextLine()) {
if(scanner.hasNextInt()){
int choice=Integer.parseInt(scanner.nextLine());
if(choice==1){
String[] personData=getPersonDetails(scanner);
System.out.print("Enter "+personData[0]+"'s class status:");
String classStatus=scanner.nextLine();
Student student=new Student(classStatus, personData);
System.out.println(student.toString());
}else if(choice==2){
String[] personData=getPersonDetails(scanner);
System.out.println("1) To create a faculty member");
System.out.println("2) To create a staff member");
System.out.println("choice: ");
int subChoice=Integer.parseInt(scanner.nextLine());
if(subChoice==1){
System.out.print("Enter Office Number: ");
int officeNumber=Integer.parseInt(scanner.nextLine());
System.out.print("Enter Salary: $");
int salary=Integer.parseInt(scanner.nextLine());
System.out.print("Enter Hire Date(mm/dd/yyyy): ");
MyDate dateHired=new MyDate(scanner.nextLine());
System.out.print("Enter Office Hours: ");
String officeHours=scanner.nextLine();
System.out.print("Enter rank: ");
String rank=scanner.nextLine();
Faculty faculty=new Faculty(personData, officeNumber, salary, dateHired, officeHours, rank);
System.out.println(faculty.toString());
}else if(subChoice==2){
System.out.print("Enter Office Number: ");
int officeNumber=Integer.parseInt(scanner.nextLine());
System.out.print("Enter Salary: $");
int salary=Integer.parseInt(scanner.nextLine());
System.out.print("Enter Hire Date(mm/dd/yyyy): ");
MyDate dateHired=new MyDate(scanner.nextLine());
System.out.print("Enter Title: ");
String title=scanner.nextLine();
Staff staff=new Staff(personData, officeNumber, salary, dateHired, title);
System.out.println(staff.toString());
}
}else{
scanner.nextLine();
System.out.println("Invalid Choice, Enter the correct choice");
}
}else{
scanner.nextLine();
System.out.println("Invalid Choice, Enter the correct choice");
}
System.out.println(" Enter the Choice:");
System.out.println("1) To create a student");
System.out.println("2) To create a employee");
System.out.print("Choice: ");
}
scanner.close();
}
public static String[] getPersonDetails(Scanner scanner) {
System.out.print("Enter a name: ");
String name=scanner.nextLine();
System.out.print("Enter "+name+"'s address: ");
String address=scanner.nextLine();
System.out.print("Enter "+name+"'s phone number: ");
String phoneNumber=scanner.nextLine();
System.out.print("Enter "+name+"'s email: ");
String email=scanner.nextLine();
String[] personData={name,address,phoneNumber,email};
return personData;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started