Advertisement
sergAccount

Untitled

Feb 14th, 2021
723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.mycompany.ja12;
  7.  
  8. import java.util.ArrayList;
  9. import java.util.List;
  10.  
  11. public class Employee {
  12.    
  13.     private String name;
  14.     private String salary;
  15.     //
  16.     private List<Employee> subordinates;
  17.        
  18.     public Employee(String name){
  19.         this.name = name;
  20.         subordinates = new ArrayList<>();
  21.     }
  22.     public void add(Employee e){
  23.         subordinates.add(e);
  24.     }
  25.     public void remove(Employee e){
  26.         subordinates.remove(e);
  27.     }
  28.     // получаем всех подчиненных
  29.     public List<Employee> getSubordinates(){
  30.         return subordinates;
  31.     }    
  32.  
  33.     public String getSalary() {
  34.         return salary;
  35.     }
  36.     public void setSalary(String salary) {
  37.         this.salary = salary;
  38.     }
  39.    
  40.    
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement