-
-
Save mamiwinsfall93/cba030e6f59b81b85b095dac63078d91 to your computer and use it in GitHub Desktop.
Employee, classes with salary information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Filename: Employee.java | |
* Author: Ndatta Fall | |
* | |
* Purpose: Employee, classes with salary information | |
* | |
*/ | |
public class Employee { | |
private String name;//to store name of employee | |
private int monthlySalary;//to store monthly salary | |
public Employee(String name, int monthlySalary) {// constructor that allows the name and montly to be initialized | |
this.name = name; | |
this.monthlySalary = monthlySalary; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public int getMonthlySalary() { | |
return monthlySalary; | |
} | |
public void setMonthlySalary(int monthlySalary) { | |
this.monthlySalary = monthlySalary; | |
} | |
public int AnnualSalary() {// method named annual salary that returns the salary for a whole year | |
int annualPay = 12 * monthlySalary; | |
return annualPay; | |
} | |
public String toString() {// returns employee's information | |
String employeeInfo = "employee's name: " + getName() | |
+ "\n" + "Monthly salary : " + getMonthlySalary() | |
+ "\n" + "Annual salary : " + AnnualSalary(); | |
return employeeInfo; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment