Provide A UML for the Following CODE
public class Employee{
public String strName, strSalary;
public Employee(){
strName = " ";
strSalary = "$0";
}
public Employee(String Name, String Salary){
strName = Name;
strSalary = Salary;
}
public void setName(String Name){
strName = Name;
}
public void setSalary(String Salary){
strSalary = Salary;
}
public String getName(){
return strName;
}
public String getSalary(){
return strSalary;
}
public String toString(){
return(strName + " has a salary of " +
strSalary);
}
}
********************************** Manager.java *************************************************
public class Manager extends Employee{
public String department;
public Manager(String name,String salary,String
department){
super(name,salary);
this.department = department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getDepartment() {
return this.department;
}
public String toString(){
return(super.strName +" manager of
department "+this.department+ " has a salary of " +
super.strSalary);
}
}
*********************************** TestDriver.java ***************************************
import java.util.Scanner;
public class TestDriver {
public static void main(String[] args) {
Scanner s = new
Scanner(System.in);
int i = 1;
int n = s.nextInt();
s.nextLine();
Manager[] arr;
if(n<=3)
arr = new Manager[n];
else
arr = new Manager[3];
while(i<=arr.length) {
System.out.println("Enter "+i+"th manager's name: ");
String name =
s.nextLine();
System.out.println("Enter "+i+"th manager's salary: ");
String salary =
s.nextLine();
System.out.print("Enter "+i+"th manager's department: ");
String
department = s.nextLine();
arr[i-1] = new
Manager(name,salary,department);
i++;
}
i=0;
while(i<arr.length) {
System.out.println(arr[i].toString());
i++;
}
}
}
UML stands for Unified Modelling Language. It is used to visualise the design of a software system. There are two broad types of UML namesly Structural and Behavioural. For our given question, we will provide a class UML diagram which falls under Structural UML diagram.
Class UML diagram consists of classes, interfaces and their association.It is useful in representing the object oriented view of a system. In our given problem we have two objects namely Employee and Manager where Manager inherits from Employee. Technically Employee class is referred to as Super class and Manager class is referred to as Sub class
Get Answers For Free
Most questions answered within 1 hours.