Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 23rd, 2013  |  syntax: None  |  size: 1.13 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class Employee {
  2.  
  3.     //global variables
  4.     private String firstName;
  5.     private String lastName;
  6.     private double monthlySalary;
  7.  
  8.     //constructor for the Employee class
  9.     public Employee(String first, String last, Double salary) {
  10.         firstName = first;
  11.         lastName = last;
  12.         monthlySalary = salary;
  13.     }
  14.  
  15.     //setter for first name
  16.     public void setFirstName(String name) {
  17.         firstName = name;
  18.     }
  19.  
  20.     //setter for last name
  21.     public void setLastName(String name) {
  22.         lastName = name;
  23.     }
  24.  
  25.     //setter for salary, only sets if
  26.     //money is > 0
  27.     public void setSalary(Double money) {
  28.         if(money > 0) {
  29.             monthlySalary = money;
  30.         }
  31.         else {
  32.             System.out.println("Salary must be greater than 0");
  33.         }
  34.     }
  35.  
  36.     //getter for first name
  37.     public String getFirstName() {
  38.         return firstName;
  39.     }
  40.  
  41.     //getter for last name
  42.     public String getLastName() {
  43.         return lastName;
  44.     }
  45.  
  46.     //getter for salary
  47.     public Double getSalary() {
  48.         return monthlySalary;
  49.     }
  50. }//end Employee class
clone this paste RAW Paste Data