Advertisement
arafaee

EmployeeStatic.java

Apr 17th, 2017
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1.  
  2. /**
  3.  * 8.12 EmployeeStatic.java
  4.  *
  5.  * @author Hafara Firdausi/ 5115100043
  6.  * @version 01
  7.  */
  8.  
  9. public class EmployeeStatic
  10. {
  11.    private String firstName;  
  12.    private String lastName;  
  13.    private static int count = 0; //number of Employees created  
  14.  
  15.    public EmployeeStatic (String first, String last)  
  16.    {  
  17.      firstName=first;  
  18.      lastName=last;  
  19.      ++count; //increment static count of employees
  20.      System.out.printf( "Employee constructor: %s %s; count = %d\n",  
  21.        firstName, lastName, count);  
  22.    }  
  23.    public String getFirstName()  
  24.    {  
  25.      return firstName;  
  26.    }  
  27.    public String getLastName()  
  28.    {  
  29.      return lastName;  
  30.    }  
  31.    public static int getCount()  
  32.    {  
  33.      return count;  
  34.    }
  35. } //end class Employee
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement