Advertisement
sararararah

Untitled

Apr 25th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. package program5;
  2.  
  3. import java.io.Serializable;
  4. import java.text.DecimalFormat;
  5.  
  6. // Write the Psuedocode
  7. public class Employee {
  8.  
  9. // instance variables
  10. private Name employeeName;
  11. private double pay;
  12.  
  13. // default constructor
  14. public Employee () {
  15.  
  16. }// end default constructor
  17. // constructor
  18. public Employee (String last, String first, String middle, String title) {
  19. employeeName = new Name (title, last, first, middle);
  20.  
  21. }// end Employee
  22.  
  23. public Name getEmployeeName () {
  24. return employeeName;
  25.  
  26. }// end getEmployeeName
  27.  
  28. public String Earnings(double pay) {
  29. return employeeName + ": " + pay;
  30.  
  31. }// end Earnings
  32.  
  33. }// end class
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. package program5;
  43.  
  44. import java.io.Serializable;
  45.  
  46. public class Name extends Employee {
  47.  
  48. // instance variables
  49. private String firstName;
  50. private String lastName;
  51. private String middleName;
  52. private String title;
  53.  
  54. public Name(String last, String first, String middle, String title)
  55. {
  56.  
  57. firstName = first;
  58. lastName = last;
  59. middleName = middle;
  60. this.title = title;
  61. }// end constructor
  62.  
  63. public String getFirstName()
  64. {
  65. return firstName;
  66. }// end getFirstName
  67.  
  68. public String getLastName()
  69. {
  70. return lastName;
  71. }// end getLastName
  72.  
  73. public String gettitle()
  74. {
  75. return title;
  76. }// end getTitle
  77.  
  78. public void setFirstName(String first)
  79. {
  80. firstName = first;
  81. }// end SetFirstName
  82.  
  83. public void setLastName(String last)
  84. {
  85. lastName = last;
  86. }// end setLastName
  87.  
  88. public void setTitle(String title)
  89. {
  90. this.title = title;
  91. }// end setTitle
  92.  
  93. public String toString()
  94. {
  95. return title + " " + lastName + ", " + firstName;
  96. }// end toString
  97.  
  98. }// end class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement