daily pastebin goal
21%
SHARE
TWEET

Quiz 2

touhidulshawan Apr 16th, 2018 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package quiz2;
  2.  
  3. public class Company {
  4.    
  5.     private String name;
  6.    
  7.     Employee[] employee = new Employee[2];
  8.    
  9.     public Company(String name) {
  10.        
  11.         this.name = name;
  12.     }
  13.    
  14.     public String getName() {
  15.        
  16.         return name;
  17.     }
  18.    
  19.     public Employee[] getEmployess() {
  20.        
  21.         return employee;
  22.     }
  23.  
  24. }
  25.  
  26.  
  27.  
  28.  
  29. public class Employee {
  30.    
  31.     private String name;
  32.     private int employeeNumber;
  33.     private double salary;
  34.    
  35.     public Employee(String name, int number, double salary) {
  36.        
  37.         this.name = name;
  38.         employeeNumber = number;
  39.         this.salary = salary;
  40.     }
  41.    
  42.     public String getName() {
  43.        
  44.         return name;
  45.     }
  46.    
  47.     public int getEmployeeNumber() {
  48.        
  49.         return employeeNumber;
  50.     }
  51.    
  52.     public double getSalary() {
  53.        
  54.         return salary;
  55.     }
  56.  
  57. }
  58.  
  59.  
  60.  
  61.  
  62. public class Main {
  63.    
  64.     public static void main(String[] args) {
  65.        
  66.         Company obj = new Company("Software Ltd");
  67.        
  68.         System.out.println("Company name :"+obj.getName());
  69.  
  70.         Employee obj2 = new Employee("Shawan",5,1200);
  71.         Employee obj3 = new Employee("Miraz",1,3000);
  72.        
  73.         System.out.println("Employee name :"+obj2.getName());
  74.         System.out.println("Employee Number : "+obj2.getEmployeeNumber());
  75.         System.out.println("Salary : "+obj2.getSalary());
  76.        
  77.         System.out.println("Employee name :"+obj3.getName());
  78.         System.out.println("Employee Number : "+obj3.getEmployeeNumber());
  79.         System.out.println("Salary : "+obj3.getSalary());
  80.        
  81.         obj.employee[0] = obj2;
  82.         obj.employee[1] = obj3;
  83.        
  84.     }
  85.  
  86. }
RAW Paste Data
Top