Advertisement
Boyan5

26-10

Oct 26th, 2021
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.33 KB | None | 0 0
  1. public class Employee {
  2.     String name;
  3.     double salary;
  4.  
  5.     public Employee() {
  6.         this.name = name;
  7.         this.salary = salary;
  8.     }
  9.  
  10.     public Employee(String name,double salary){
  11.         this.name =  name;
  12.         this.salary = salary;
  13.     }
  14.     public String toString() {
  15.         return toString() + name + salary;
  16.     }
  17.  
  18.     public void setName(String name) {
  19.  
  20.         this.name = name;
  21.     }
  22.  
  23.     public String getName() {
  24.  
  25.         return name;
  26.     }
  27.  
  28.     public void setSalary(double salary) {
  29.         this.salary = salary;
  30.     }
  31.  
  32.     public double getSalary() {
  33.         return salary;
  34.     }
  35.  
  36. }
  37.  
  38.  
  39. public class Manager extends Employee {
  40.     double bonus;
  41.  
  42.     public Manager() {
  43.         super();
  44.         this.bonus = bonus;
  45.     }
  46.  
  47.     public Manager(String name, double salary, double bonus) {
  48.         super(name,salary);
  49.         this.bonus = bonus;
  50.     }
  51.     public String toString() {
  52.         return super.toString() + bonus;
  53.     }
  54.  
  55.     public void setBonus(double bonus) {
  56.         this.bonus = bonus;
  57.     }
  58.  
  59.     public double getBonus() {
  60.         return bonus;
  61.     }
  62.  
  63. }
  64.  
  65.  
  66. public class Secretary extends Employee{
  67.     String languages;
  68.     public Secretary(){
  69.         super();
  70.         this.languages = languages;
  71.     }
  72.  
  73.     public Secretary(String name, double salary,String languages){
  74.         super(name,salary);
  75.         this.languages = languages;
  76.     }
  77.  
  78.     public String toString() {
  79.  
  80.         return  super.toString() + languages ;
  81.     }
  82.  
  83.     public void setLanguages(String languages) {
  84.  
  85.         this.languages = languages;
  86.     }
  87.  
  88.     public String getLanguages() {
  89.  
  90.         return languages;
  91.     }
  92.  
  93. }
  94.  
  95. public class TestEmployee {
  96.     public static void main(String[] args) {
  97.         Employee employee = new Employee ("Ivan Petkov", 3013.76);
  98.         Manager manager = new Manager("Dimitar Pavlov",4557.12,445.80);
  99.         Secretary secretary = new Secretary("Andrea Ilieva",1887.23,"Spanish, French, English");
  100.         System.out.println("Employee: " + employee.getName() + ", "+ employee.getSalary());
  101.         System.out.println("Manager: " + manager.getName() + ", " + manager.getSalary() + ", " + manager.getBonus());
  102.         System.out.println("Secretary: " + secretary.getName() + ", " + secretary.getSalary() + ", " + secretary.getLanguages());
  103.     }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement