Ramirez_RD

rate without encapsulation

Sep 11th, 2025
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. public class EmployeeLastNameFirstName {
  2.     public String name;
  3.     public String emailAddress;
  4.     public int hoursWorked;
  5.     public double rate;
  6.     public EmployeeLastNameFirstName(String name, String emailAddress, int hoursWorked, double rate){
  7.         this.name = name;
  8.         this.emailAddress = emailAddress;
  9.         this.hoursWorked = hoursWorked;
  10.         this.rate = rate;
  11.     }
  12.     public void setName(String neym){
  13.         this.name = neym;
  14.     }
  15.     public void setEmailAddress(String email){
  16.         this.emailAddress = email;
  17.     }
  18.     public void setHoursWorked(int hrs){
  19.         this.hoursWorked = hrs;
  20.     }
  21.     public void setRatePH(double rph){
  22.         this.rate = rph;
  23.     }
  24.     public String getName(){
  25.         return this.name;
  26.     }
  27.     public String getEmailAddress(){
  28.         return this.emailAddress;
  29.     }
  30.     public int getHoursWorked(){
  31.         return this.hoursWorked;
  32.     }
  33.     public double getRate(){
  34.         return this.rate;
  35.     }
  36.     public double getWage(){
  37.         return this.rate * this.hoursWorked;
  38.     }
  39.     public static void main(String[] args) {
  40.         EmployeeLastNameFirstName employee = new EmployeeLastNameFirstName("Samson Angel", "[email protected]", 40, 725.50);
  41.         System.out.println("Name: " + employee.name);
  42.         System.out.println("Email: " + employee.emailAddress);
  43.         System.out.println("Rate: " + employee.rate);
  44.         System.out.println("Number of Hours Worked: " + employee.hoursWorked);
  45.         System.out.println("Wage: " + employee.getWage());
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment