Question

Provide A UML for the Following CODE public class Employee{ public String strName, strSalary; public Employee(){...

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++;
       }
   }

}

Homework Answers

Answer #1

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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Fix the program: what if the input is three? import java.util.Scanner public class Test { public...
Fix the program: what if the input is three? import java.util.Scanner public class Test { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter an integer: "); int m = in.nextInt(); System.out.print("Enter another integer: "); int n = in.nextInt(); System.out.println(m + " " + n); } }
please fix code to delete by studentname import java.util.Scanner; public class COurseCom666 {     private String...
please fix code to delete by studentname import java.util.Scanner; public class COurseCom666 {     private String courseName;     private String[] students = new String[1];     private int numberOfStudents;     public COurseCom666(String courseName) {         this.courseName = courseName;     }     public String[] getStudents() {         return students;     }     public int getNumberOfStudents() {         return numberOfStudents;     }     public void addStudent(String student) {         if (numberOfStudents == students.length) {             String[] a = new String[students.length + 1];            ...
import java.util.Scanner; public class FindMinLength { public static int minLength(String[] array) { int minLength = array[0].length();...
import java.util.Scanner; public class FindMinLength { public static int minLength(String[] array) { int minLength = array[0].length(); for (int i = 0; i < array.length; i++) { if (array[i].length() < minLength) minLength = array[i].length(); } return minLength; } public static void main(String[] args) { Scanner in = new Scanner(System.in); String[] strings = new String[50]; for (int i = 0; i < strings.length; i++) { System.out.print("Enter string " + (i + 1) + ": "); strings[i] = in.nextLine(); } System.out.println("Length of smallest...
Please explain code 1 and code 2 for each lines code 1 public class MyQueue {...
Please explain code 1 and code 2 for each lines code 1 public class MyQueue {    public static final int DEFAULT_SIZE = 10;    private Object data[];    private int index; code 2 package test; import java.util.*; /* Class Node */ class Node { protected Object data; protected Node link; /* Constructor */ public Node() { link = null; data = 0; } /* Constructor */ public Node(Object d,Node n) { data = d; link = n; } /*...
I am a beginner when it comes to java codeing. Is there anyway this code can...
I am a beginner when it comes to java codeing. Is there anyway this code can be simplified for someone who isn't as advanced in coding? public class Stock { //fields private String name; private String symbol; private double price; //3 args constructor public Stock(String name, String symbol, double price) { this.name = name; this.symbol = symbol; setPrice(price); } //all getters and setters /** * * @return stock name */ public String getName() { return name; } /** * set...
JAVA public class Purchase { private String name; private int groupCount; //Part of price, like the...
JAVA public class Purchase { private String name; private int groupCount; //Part of price, like the 2 in 2 for $1.99. private double groupPrice; //Part of price, like the $1.99 in 2 for $1.99. private int numberBought; //Total number being purchased. public Purchase () { name = "no name"; groupCount = 0; groupPrice = 0; numberBought = 0; } public Purchase (String name, int groupCount, double groupPrice, int numberBought) { this.name = name; this.groupCount = groupCount; this.groupPrice = groupPrice; this.numberBought...
in java need uml diagram import java.util.ArrayList; import java.util.*; public class TodoList { String date=""; String...
in java need uml diagram import java.util.ArrayList; import java.util.*; public class TodoList { String date=""; String work=""; boolean completed=false; boolean important=false; public TodoList(String a,String b,boolean c,boolean d){ this.date=a; this.work=b; this.completed=c; this.important=d; } public boolean isCompleted(){ return this.completed; } public boolean isImportant(){ return this.important; } public String getDate(){ return this.date; } public String getTask(){ return this.work; } } class Main{ public static void main(String[] args) { ArrayList<TodoList> t1=new ArrayList<TodoList>(); TodoList t2=null; Scanner s=new Scanner(System.in); int a; String b="",c=""; boolean d,e; char...
Sort by the following (name, address, dependent and gender) of these and ask the user which...
Sort by the following (name, address, dependent and gender) of these and ask the user which field to sort by !. this mean the following java must sort by address if we need, by name , by dependent , and by gender it depend on the following java it must have an option which we need to sort. please i need your help now, you just add the sorting on the following java. // Use a custom comparator. import java.io.BufferedReader;...
import java.util.Stack; import java.util.Scanner; class Main { public static void main(String[] args)    {       ...
import java.util.Stack; import java.util.Scanner; class Main { public static void main(String[] args)    {        Stack<Integer> new_stack = new Stack<>();/* Start with the empty stack */        Scanner scan = new Scanner(System.in);        int num;        for (int i=0; i<10; i++){//Read values            num = scan.nextInt();            new_stack.push(num);        }        int new_k = scan.nextInt(); System.out.println(""+smallerK(new_stack, new_k));    }     public static int smallerK(Stack s, int k) {       ...
This code it's not working, fix it for me please #include <iostream> using namespace std; class...
This code it's not working, fix it for me please #include <iostream> using namespace std; class People {    string name;    double height; public:    void setName(string name)    {        this->name = name;    }    void setHeight(double height)    {        this->height = height;    }    double getHeight() {        return height;    }    string getName()    {        return name;    } }; int main() {    const int size...