NAD M.

asked • 11/23/20

Converting Java Code to a UML diagram

I need to convert this program in java to UML diagram :

please help me .


//super calss

public class Employee {

// Defines class Employees


// Instance variables to store employee information

private int ID;

private String name;

private String address;

private String mobileNumber;

private String email;

private double salary;

// Default constructor to assign default values to instance variables

public Employee()

{

ID = 0;

name = address = mobileNumber = email = null;

salary = 0.0;

}

// Parameterized constructor to assign parameter values to instance variables


public Employee(int ID, String name, String address, String mobileNumber, String email, double salary) {

this.ID = ID;

this.name = name;

this.address = address;

this.mobileNumber = mobileNumber;

this.email = email;

this.salary = salary;

}

// Getter method

public int getID()

{

return ID;

}

public String getName()

{

return name;

}

public String getAddress()

{

return address;

}

public String getMobileNumber()

{

return mobileNumber;

}

public String getEmail()

{

return email;

}

public double getSalary()

{

return salary;

}

// Setter method

public void setID(int ID)

{

this.ID = ID;

}

public void setName(String name)

{

this.name = name;

}

public void setAddress(String address)

{

this.address = address;

}

public void setMobileNumber(String mobileNumber)

{

this.mobileNumber = mobileNumber;

}

public void setEmail(String email)

{

this.email = email;

}

public void setSalary(double salary)

{

this.salary = salary;

}

// Overrides method toString() to return employee information

public String toString()

{

return "\n Name: " + name + "\n Address: " + address +

"\n Mobile Number: " + mobileNumber + "\n Email: " + email +

"\n Salary: $" + salary;

}

}// End of class Emoloyees




// Defines derived class AdministrationStaff extends super class Employees

class AdministrationStaff extends Employee {

// Instance variable to store position

private String position;

// Default constructor to assign default value to instance variable position

public AdministrationStaff()

{

// Calls base class default constructor

super();

position = "";

}

// Parameterized constructor to assign parameter values to instance variables

public AdministrationStaff(int ID, String name, String address, String mobileNumber,

String email, double salary, String position)

{

// Calls base class parameterized constructor

super(ID, name, address, mobileNumber, email, salary);

this.position = position;

}

// Getter method to return position

public String getPosition()

{

return position;

}

// Setter method to change position

public void setPosition(String position)

{

this.position = position;

}

// Overrides method toString() to return administration staff information

public String toString()

{

return super.toString() + "\n Position: " + position;

}

}// End of class AdministrationStaff





// Defines derived class Doctor extends super class Employees

class Doctor extends Employee {

// Instance variable to store rank and speciality

private String rank;

private String specialty;

// Default constructor to assign default value to instance variable position

public Doctor()

{

// Calls base class default constructor

super();

rank = specialty = "";

}

// Parameterized constructor to assign parameter values to instance variables

public Doctor(int ID, String name, String address, String mobileNumber,

String email, double salary, String rank, String specialty)

{

// Calls base class parameterized constructor

super(ID, name, address, mobileNumber, email, salary);

this.rank = rank;

this.specialty = specialty;

}

// Getter method to return rank

public String getRank()

{

return rank;

}

// Getter method to return speciality

public String getSpeciality()

{

return specialty;

}

// Setter method to change rank

public void setRank(String rank)

{

this.rank = rank;

}

// Setter method to change specialty

public void setSpeciality(String speciality)

{

this.specialty = speciality;

}

// Overrides method toString() to return doctor information

public String toString()

{

return super.toString() + "\n Rank: " + rank + "\n Speciality: " + specialty;

}

}// End of class Doctor



NAD M.

and also : // Defines class Patients class Patient { // Instance variables to store patient information private int patientID; private String patientName; private String patientAddress; private String patientMobileNumber; private String patientEmail; private char type; ArrayList services; // Default constructor to assign default value to instance variable public Patient() { patientID = 0; patientName = patientAddress = patientMobileNumber = patientEmail = ""; type = ' '; services = new ArrayList(); } // Parameterized constructor to assign parameter values to instance variables public Patient(int pID, String pn, String pa, String pm, String pe, char ty, ArrayList ser) { patientID = pID; patientName = pn; patientAddress = pa; patientMobileNumber = pm; patientEmail = pe; type = ty; services = new ArrayList(); services = ser; } // Getter method to return patient id public int getPatientID() { return patientID; } // Getter method to return patient name public String getPatientName() { return patientName; } // Getter method to return patient address public String getPatientAddress() { return patientAddress; } // Getter method to return patient mobile number public String getPatientMobileNumber() { return patientMobileNumber; } // Getter method to return patient email public String getPatientEmail() { return patientEmail; } // Getter method to return patient type public char getType() { return type; } // Getter method to return patient services public ArrayList getServices() { return services; } // Setter method to change patient id public void setPatientID(int pID) { patientID = pID; } // Setter method to change patient name public void setPatientName(String pn) { patientName = pn; } // Setter method to change patient address public void setPatientAddress(String pa) { patientAddress = pa; } // Setter method to change patient mobile number public void setPatientMobileNumber(String pm) { patientMobileNumber = pm; } // Setter method to change patient email public void setPatientEmail(String pe) { patientEmail = pe; } // Setter method to change patient type public void setType(char ty) { type = ty; } // Setter method to change patient services public void getServices(ArrayList ser) { services = ser; } // Overrides method toString() to return service information public String toString() { String result = ""; result += "\n Patient ID: " + patientID + "\n Patient Name: " + patientName + "\n Patient Address: " + patientAddress + "\n Patient Mobile Number: " + patientMobileNumber + "\n Patient Email Address: " + patientEmail + "\n Patient Type: " + type + "\n\n **** Service Availed **** "; // Loops number of services availed for(int c = 0; c < services.size(); c++) result += services.get(c).toString() + "\n"; return result; } }// End of class Patients
Report

11/23/20

NAD M.

and the last class in program i need to converting to UML : public class Service { // Instance variable to store service information private int serviceID; private String serviceName; private double servicePrice; // Default constructor to assign default value to instance variable public Service() { serviceID = 0; serviceName = ""; servicePrice = 0.0; } // Parameterized constructor to assign parameter values to instance variables public Service(int sID, String sn, double price) { serviceID = sID; serviceName = sn; servicePrice = price; } // Getter method to return service id public int getServiceID() { return serviceID; } // Getter method to return service name public String getServiceName() { return serviceName; } // Getter method to change service price public double getServicePrice() { return servicePrice; } // Setter method to change service id public void setServiceID(int sID) { serviceID = sID; } // Setter method to change service name public void setServiceName(String sn) { serviceName = sn; } // Setter method to change service price public void setServicePrice(double price) { servicePrice = price; } // Overrides method toString() to return service information public String toString() { return "\n Service ID: " + serviceID + "\n Service Name: " + serviceName + "\n Price: $" + servicePrice; } }// End of class Service
Report

11/23/20

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.