Advertisement
RavenSH

extend

Apr 11th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.36 KB | None | 0 0
  1. package employee;
  2.  
  3. public class Employee {
  4.     public static long empID;
  5.     public static String name;
  6.  
  7.    public Employee (String name, int empID) {
  8.    Employee.name = name;
  9.    Employee.empID = empID;
  10.  
  11.    
  12.    }
  13.    public void setEmpID (int empID) {
  14.    Employee.empID = empID;
  15.    System.out.println(Employee.empID);
  16.    }
  17.    public void setName (String name) {
  18.    Employee.name = name;
  19.    System.out.println(Employee.name);
  20.    }
  21.    
  22.  
  23.    public static void main(String[] args) {
  24.        Employee empl = new Employee ("Barbara" , 102);
  25.        if (name != null) {
  26.            System.out.printf("Employee name is: "+name + "\n" + "Employee ID is: " + empID);
  27.        }
  28.        else {
  29.            System.out.println("No active name");
  30.       }
  31.    }
  32.        public class Manager extends Employee {
  33.        private String lastName;
  34.      
  35.  
  36.         public Manager(String name, int empID, String lastName) {
  37.             super(name, empID);
  38.             this.lastName = lastName;
  39.             lastName = "Santos";
  40.             if (name != null) {
  41.            System.out.println("Manager lastname is: " + lastName
  42.                      + "\n" + "Managers ID is: " + empID
  43.                      + "\n" + "Managers name is: " + name);
  44.        }
  45.        else {
  46.            System.out.println("No active name");
  47.       }
  48.        
  49.         }
  50.        
  51.        }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement