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
Q:Could you fill in the blank。 class Employee{ // field private String name; private (1) _float__...
Q:Could you fill in the blank。 class Employee{ // field private String name; private (1) _float__ salary; // constructor (2) ________________________________________ // method public (3) __String____ getName( ){ return name; } public float getSalary( ){ return Salary; } public (4) ________ compare( (5) _________________ { (6) ____________________________________ } }// class Employee public class EmployeeUI{ public static void main(String[ ] args){ Employee e1 = new Employee(“William”); Employee e2 = new Employee(“Rchard”); if(Employee.compare(e1, e2)) System.out.println(“same employee”); else System.out.println(“different employee”); } }//class EmployeeUI
How do I make this: public class Country {     private String name;     private double area;     private...
How do I make this: public class Country {     private String name;     private double area;     private int population;     public Country(String name, double area, int population) {         this.name = name;         this.area = area;         this.population = population;     }     public double getPopulationDensity() {         return population / area;     }     public String getName() {         return name;     }     public void setName(String name) {         this.name = name;     }     public double getArea() {         return area;     }     public void setArea(double area) {         this.area = area;     }     public int getPopulation()...
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];            ...
<<<<<<<< I need only the UML diagram for ALL classes.Java???????????? public class House {    private...
<<<<<<<< I need only the UML diagram for ALL classes.Java???????????? public class House {    private int houseNumber;    private int bedrooms;    private int sqFeet;    private int year;    private int cost;    public House(int houseNumber,int bedrooms,int sqFeet, int year, int cost)    {        this.houseNumber = houseNumber;        this.bedrooms = bedrooms;        this.sqFeet = sqFeet;        this.year = year;        this.cost = cost;    }    public int getHouseNumber()    {        return houseNumber;    }   ...
Determine how all of your classes are related, and create a complete UML class diagram representing...
Determine how all of your classes are related, and create a complete UML class diagram representing your class structure. Don't forget to include the appropriate relationships between the classes. GameDriver import java.util.Scanner; public class GameDriver { Scanner in = new Scanner(System.in); public static void main(String[] args) { Move move1 = new Move("Vine Whip", "Grass", 45, 1.0f); Move move2 = new Move("Tackle", "Normal", 50, 1.0f); Move move3 = new Move("Take Down", "Normal", 90, 0.85f); Move move4 = new Move("Razor Leaf", "Grass",...
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...
public class Lab1 { public static void main(String[] args) { int array [] = {10, 20,...
public class Lab1 { public static void main(String[] args) { int array [] = {10, 20, 31, 40, 55, 60, 65525}; System.out.println(findPattern(array)); } private static int findPattern(int[] arr) { for (int i = 0; i < arr.length - 2; i++) { int sum = 0; for (int j = i; j < i + 2; j++) { sum += Math.abs(arr[j] - arr[j + 1]); // finding the difference } if (sum == 20) return i; } return -1; } }...
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...
Please find the BigO function with explanation for each of the programs below: - Recursive binary...
Please find the BigO function with explanation for each of the programs below: - Recursive binary search - Computing the factorial of N - Computing the N-th Fibonacci number. import java.util.Scanner; public class Recursive { public static void main(String args[]) { int arr[]= {7,9,12,15,28,57,92}; Scanner in = new Scanner(System.in); int key; System.out.print("Enter key to search in array : "); key = in.nextInt(); int index = binarySearch(arr,0,arr.length-1,key); if(index==-1)System.out.println(key + " is not found in array\n"); else System.out.println(key + " is found...
Consider the following snippet of code: public class Animal { public String name; private int age;...
Consider the following snippet of code: public class Animal { public String name; private int age; public Animal() {   this.name = “defaultAnimal”;   this.age = 0; } public Animal (String name, int age) {   this.name = name;   this.age = age; } public String getName() { return this.name; } public int getAge() { return this.age; } } public class Dog extends Animal { //code } Of the following methods, which will lead to errors using the “super” keyword, if placed in the...