Advertisement
Arush22

Untitled

Apr 23rd, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. package Suarez;
  2.  
  3. public class Employee {
  4. private int years;
  5. public Employee(int initialYears){
  6. years = initialYears;
  7. }
  8. public int getHours(){
  9. return 40;
  10. }
  11. public double getSalary(){
  12. return 40000.00;
  13. }
  14. public int getVacationDay(){
  15. return 40 + 2*getSeniorityBonus();
  16. }
  17. public int getYears(){
  18. return years;
  19. }
  20. public String getVacationForm(){
  21. return "yellow";
  22. }
  23. public int getSeniorityBonus(){
  24. return 2*years;
  25. }
  26. }
  27.  
  28.  
  29. package Suarez;
  30.  
  31. public class Secretary extends Employee {
  32. private int LSYs;
  33. public Secretary(int years, int legalSecretaryYears){
  34. super(years);
  35. LSYs = legalSecretaryYears;
  36. }
  37. public Secretary(int legalSecretaryYears){
  38. super(0);
  39. LSYs = legalSecretaryYears;
  40. }
  41. public void takeDictation(String text) {
  42. System.out.println("Taking dictation of text" + text);
  43. }
  44. public int getSeniorityBonus(){
  45. return 0;
  46. }
  47. }
  48.  
  49.  
  50.  
  51.  
  52.  
  53. package Suarez;
  54.  
  55. public class EmployeeClient {
  56. public static void main(String [] args){
  57. Employee Aarian = new Lawyer(5);
  58. System.out.println(Aarian.getSalary());
  59. System.out.println(Aarian.getVacationForm());
  60. System.out.println();
  61. Employee[] employed = {new Lawyer(10), new Secretary(11), new Marketer(12), new LegalSecretary(23)};
  62. for(int i = 0; i < employed.length; i++){
  63. System.out.println("Salary: "+employed[i].getSalary());
  64. System.out.println("Salary: "+employed[i].getVacationDay());
  65. System.out.println();
  66. }
  67.  
  68. }
  69. }
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76. package Suarez;
  77. import java.util.*;
  78. public class Lawyer extends Employee {
  79. public Lawyer(int years){
  80. super(years);
  81. }
  82. public void sue(String text){
  83. Scanner input = new Scanner(System.in);
  84. System.out.println("Who do you want to sue?");
  85. String target = input.next();
  86. System.out.println(target + " has been sued.");
  87. }
  88. public double getSalary(){
  89. return 40000.00 + 5000*super.getYears();
  90. }
  91. public String getVacationForm(){
  92. return "pink";
  93. }
  94. public int getVacationDays(){
  95. return super.getVacationDay()+5;
  96. }
  97. }
  98.  
  99.  
  100.  
  101.  
  102.  
  103. package Suarez;
  104. public class Marketer extends Employee {
  105. public Marketer(int years){
  106. super(years);
  107. }
  108. public void adverstise(String text){
  109. System.out.println("Join us today.");
  110. }
  111. public double getSalary(){
  112. return super.getSalary()+10000.00;
  113. }
  114. }
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121. package Suarez;
  122.  
  123. public class LegalSecretary extends Secretary {
  124. public LegalSecretary(int years){
  125. super(years);
  126. }
  127. public void adverstise(String text){
  128. System.out.println("Your document has been prepared.");
  129. }
  130. public double getSalary(){
  131. return super.getSalary()+5000.00;
  132. }
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement