Guest User

Untitled

a guest
Jan 18th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. class Employee
  2. attr_reader :first_name, :last_name, :salary, :active
  3. attr_writer :active
  4.  
  5. def initialize(input_options)
  6. @first_name = input_options[:first_name]
  7. @last_name = input_options[:last_name]
  8. @salary = input_options[:salary]
  9. @active = input_options[:active]
  10. end
  11.  
  12. def print_info
  13. puts "#{first_name} #{last_name} makes #{salary} a year."
  14. end
  15.  
  16. def give_annual_raise
  17. @salary = @salary * 1.05
  18. end
  19. end
  20.  
  21. employee_1 = Employee.new(
  22. first_name: "Bruce",
  23. last_name: "Wayne",
  24. salary: 70000,
  25. active: true
  26. )
  27.  
  28. employee_2 = Employee.new(
  29. first_name: "Diana",
  30. last_name: "Prince",
  31. salary: 80000,
  32. active: true
  33. )
  34. employee_2.print_info
  35. p employee_1.active
  36. employee_1.active = false
  37. p employee_1.active
  38.  
  39.  
  40.  
  41.  
  42. #tuesday
  43.  
  44. class Manager < Employee
  45. def initialize(input_options)
  46. super
  47.  
  48. @employees = input_options[:employees]
  49. end
  50. def send_report
  51. puts "Sending Email.."
  52. #code that sends email
  53. puts "Email sent."
  54. end
  55.  
  56. end
  57.  
  58. manager = Manager.new(
  59. first_name: "Clark",
  60. last_name: "kent",
  61. salary: 100000,
  62. active: true,
  63. employees: [employee_1, employee_2]
  64. )
  65.  
  66. manager.print_info
  67. p manager.send_report
Add Comment
Please, Sign In to add comment