SlideShare a Scribd company logo
1 of 22
Download to read offline
package employeeType.employee;
public class Employee {
private String firstName;
private String lastName;
private char middleInitial;
private boolean fulltime;
private char gender;
private int employeeNum;
public Employee(String firstName, String lastName, char middleInitial,char gender,int
employeeNum,boolean fulltime )
{
setFirstName(firstName);
setLastName(lastName);
setMiddleInitial(middleInitial);
setFulltime(fulltime);
setGender(gender);
setEmployeeNum(employeeNum);
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public char getMiddleInitial() {
return middleInitial;
}
public void setMiddleInitial(char middleInitial) {
this.middleInitial = middleInitial;
}
public boolean isFulltime() {
return fulltime;
}
public void setFulltime(boolean fulltime) {
this.fulltime = fulltime;
}
public char getGender() {
return gender;
}
public void setGender(char gender) {
if(gender=='M' || gender=='F')
{
this.gender = gender;
}
else
{
this.gender='F';
}
}
public int getEmployeeNum() {
return employeeNum;
}
public void setEmployeeNum(int employeeNum) {
while(true)
{
if(employeeNum>=10000 && employeeNum<=99999)
{
this.employeeNum = employeeNum;
}
else
{
new IllegalArgumentException("Invalid Employee Num.should be between 10000 and
99999(inclusive) ");
continue;
}
}
}
Override(Have to keep at the rate symbol before the override where ever it is in this project)
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Employee other = (Employee) obj;
if (employeeNum != other.employeeNum)
return false;
if (firstName == null) {
if (other.firstName != null)
return false;
} else if (!firstName.equals(other.firstName))
return false;
if (fulltime != other.fulltime)
return false;
if (gender != other.gender)
return false;
if (lastName == null) {
if (other.lastName != null)
return false;
} else if (!lastName.equals(other.lastName))
return false;
if (middleInitial != other.middleInitial)
return false;
return true;
}
Override
public String toString() {
System.out.println(getEmployeeNum());
System.out.println(getFirstName()+", "+getLastName()+" "+getMiddleInitial());
System.out.println("Gender: "+getGender());
if(isFulltime())
{
System.out.println("Status: Full Time");
}
else
{
System.out.println("Status: Part Time");
}
return " ";
}
}
_____________________________________________________________________
package employeeType.subTypes;
import employeeType.employee.Employee;
public class HourlyEmployee extends Employee {
private double wage;
private double hoursWorked;
public HourlyEmployee(String firstName, String lastName,
char middleInitial, char gender,int employeeNum ,boolean fulltime ,double wage) {
super(firstName, lastName, middleInitial, gender, employeeNum, fulltime);
setWage(wage);
setHoursWorked(0.0);
}
public double getWage() {
return wage;
}
public void setWage(double wage) {
this.wage = wage;
}
public double getHoursWorked() {
return hoursWorked;
}
public void setHoursWorked(double hoursWorked) {
this.hoursWorked = hoursWorked;
}
public void increaseHours(double hours)
{
if(hours>0)
hoursWorked=hoursWorked+hours;
else
throw new IllegalArgumentException("Hours Should be Greater than 0");
}
public double calculateWeeklyPay()
{
double pay=0.0;
if(getHoursWorked()<=40)
pay= getHoursWorked()*getWage();
else if(getHoursWorked()>40)
pay= 40*getWage()+(getHoursWorked()-40)*2*getWage();
return pay;
}
public void annualRaise()
{
wage=getWage()+(Math.round((getWage()*0.05)*100)/100);
}
public double holidayBonus()
{
return 40*getWage();
}
public void resetWeek()
{
hoursWorked=0;
}
Override
public String toString() {
super.toString();
System.out.println("Wage: "+getWage());
System.out.println("Hours Worked: "+getHoursWorked());
return " ";
}
}
__________________________________________________________________________
package employeeType.subTypes;
import employeeType.employee.Employee;
public class SalaryEmployee extends Employee {
private double salary;
public SalaryEmployee(String firstName, String lastName,
char middleInitial, char gender, int employeeNum, boolean fulltime,double salary) {
super(firstName, lastName, middleInitial, gender, employeeNum, fulltime);
setSalary(salary);
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public double calculateWeeklyPay()
{
return getSalary()/52;
}
public void annualRaise()
{
salary=getSalary()+(Math.round((getSalary()*0.06)*100)/100);
}
public double holidayBonus()
{
return getSalary()*0.03;
}
public void resetWeek()
{
}
Override
public String toString() {
super.toString();
System.out.println("Salary: "+getSalary());
return " ";
}
}
________________________________________________________________________
package employeeType.subTypes;
import employeeType.employee.Employee;
public class CommissionEmployee extends Employee {
private double sales;
private double rate;
public CommissionEmployee(String firstName, String lastName,
char middleInitial, char gender,int employeeNum ,boolean fulltime ,double rate) {
super(firstName, lastName, middleInitial, gender, employeeNum, fulltime);
setSales(rate);
setSales(0.0);
}
public double getSales() {
return sales;
}
public void setSales(double sales) {
this.sales = sales;
}
public double getRate() {
return rate;
}
public void setRate(double rate) {
this.rate = rate;
}
public void increaseSales(double sales)
{
if(sales<0)
throw new IllegalArgumentException("Sales Must be greater than 0");
else
sales=getSales()+sales;
}
public double calculateWeeklyPay()
{
return getRate();
}
public void annualRaise()
{
rate=(getRate()+0.02);
}
public double holidayBonus()
{
return 0.0;
}
public void resetWeek()
{
setSales(0.0);
}
Override
public String toString() {
super.toString();
System.out.println("Rate: "+getRate());
System.out.println("Sales: "+getSales());
return " ";
}
}
__________________________________________________________________________
package employeeType.employee;
import employeeType.subTypes.HourlyEmployee;
import employeeType.subTypes.SalaryEmployee;
import employeeType.subTypes.CommissionEmployee;
import java.util.Scanner;
public class EmployeeTest
{
public static void main(String args[])
{
//Create references for our objects
HourlyEmployee hourly;
SalaryEmployee salary;
CommissionEmployee commission;
//The sum of all bonuses will be placed here
double bonusPayout = 0;
//Create and print a new HourlyEmployee
hourly = HourlyFactory();
System.out.printf(" %s ", hourly);
//Create and print a new SalaryEmployee
salary = SalaryFactory();
System.out.printf(" %s ", salary);
//Create and print a new CommissionEmployee
commission = CommissionFactory();
System.out.printf(" %s ", commission);
//Alter some values of Hourly and Commission
System.out.println("Increasing Hourly's hours worked by 50.");
hourly.increaseHours(50);
System.out.println("Increasing Commissions's sales by 150,000. ");
commission.increaseSales(150000);
//Output weekly pay for each Employee
System.out.printf("Hourly Payout: %.2f ", hourly.calculateWeeklyPay());
System.out.printf("Salary Payout: %.2f ", salary.calculateWeeklyPay());
System.out.printf("Commission Payout: %.2f  ", commission.calculateWeeklyPay());
//Find total bonus payout
System.out.println("Finding total bonus payout...");
bonusPayout += hourly.holidayBonus();
bonusPayout += salary.holidayBonus();
bonusPayout += commission.holidayBonus();
System.out.printf("Bonus Payout is %.2f  ", bonusPayout);
//Reset the week and apply raises to all Employees
System.out.println("Applying annual raises and resetting week...");
hourly.resetWeek();
hourly.annualRaise();
salary.resetWeek();
salary.annualRaise();
commission.resetWeek();
commission.annualRaise();
//Output Employees after changes
System.out.printf("%s %s %s ", hourly, salary, commission);
}
//Retrieve input and create HourlyEmployee
public static HourlyEmployee HourlyFactory()
{
System.out.println("Creating HourlyEmployee...");
return new HourlyEmployee("Steve", "Rogers", 'A', 'M', 12345, true, 15.34);
}
//Retrieve input and create SalaryEmployee
public static SalaryEmployee SalaryFactory()
{
System.out.println("Creating SalaryEmployee...");
return new SalaryEmployee("Kitty", "Pryde", 'X', 'F', 54321, true, 75000);
}
//Retrieve input and create CommissionEmployee
public static CommissionEmployee CommissionFactory()
{
System.out.println("Creating CommissionEmployee...");
return new CommissionEmployee("Johnny", "Storm", 'F', 'L', 976499, false, 2.5);
}
}
________________________________________________________________________
Solution
package employeeType.employee;
public class Employee {
private String firstName;
private String lastName;
private char middleInitial;
private boolean fulltime;
private char gender;
private int employeeNum;
public Employee(String firstName, String lastName, char middleInitial,char gender,int
employeeNum,boolean fulltime )
{
setFirstName(firstName);
setLastName(lastName);
setMiddleInitial(middleInitial);
setFulltime(fulltime);
setGender(gender);
setEmployeeNum(employeeNum);
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public char getMiddleInitial() {
return middleInitial;
}
public void setMiddleInitial(char middleInitial) {
this.middleInitial = middleInitial;
}
public boolean isFulltime() {
return fulltime;
}
public void setFulltime(boolean fulltime) {
this.fulltime = fulltime;
}
public char getGender() {
return gender;
}
public void setGender(char gender) {
if(gender=='M' || gender=='F')
{
this.gender = gender;
}
else
{
this.gender='F';
}
}
public int getEmployeeNum() {
return employeeNum;
}
public void setEmployeeNum(int employeeNum) {
while(true)
{
if(employeeNum>=10000 && employeeNum<=99999)
{
this.employeeNum = employeeNum;
}
else
{
new IllegalArgumentException("Invalid Employee Num.should be between 10000 and
99999(inclusive) ");
continue;
}
}
}
Override(Have to keep at the rate symbol before the override where ever it is in this project)
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Employee other = (Employee) obj;
if (employeeNum != other.employeeNum)
return false;
if (firstName == null) {
if (other.firstName != null)
return false;
} else if (!firstName.equals(other.firstName))
return false;
if (fulltime != other.fulltime)
return false;
if (gender != other.gender)
return false;
if (lastName == null) {
if (other.lastName != null)
return false;
} else if (!lastName.equals(other.lastName))
return false;
if (middleInitial != other.middleInitial)
return false;
return true;
}
Override
public String toString() {
System.out.println(getEmployeeNum());
System.out.println(getFirstName()+", "+getLastName()+" "+getMiddleInitial());
System.out.println("Gender: "+getGender());
if(isFulltime())
{
System.out.println("Status: Full Time");
}
else
{
System.out.println("Status: Part Time");
}
return " ";
}
}
_____________________________________________________________________
package employeeType.subTypes;
import employeeType.employee.Employee;
public class HourlyEmployee extends Employee {
private double wage;
private double hoursWorked;
public HourlyEmployee(String firstName, String lastName,
char middleInitial, char gender,int employeeNum ,boolean fulltime ,double wage) {
super(firstName, lastName, middleInitial, gender, employeeNum, fulltime);
setWage(wage);
setHoursWorked(0.0);
}
public double getWage() {
return wage;
}
public void setWage(double wage) {
this.wage = wage;
}
public double getHoursWorked() {
return hoursWorked;
}
public void setHoursWorked(double hoursWorked) {
this.hoursWorked = hoursWorked;
}
public void increaseHours(double hours)
{
if(hours>0)
hoursWorked=hoursWorked+hours;
else
throw new IllegalArgumentException("Hours Should be Greater than 0");
}
public double calculateWeeklyPay()
{
double pay=0.0;
if(getHoursWorked()<=40)
pay= getHoursWorked()*getWage();
else if(getHoursWorked()>40)
pay= 40*getWage()+(getHoursWorked()-40)*2*getWage();
return pay;
}
public void annualRaise()
{
wage=getWage()+(Math.round((getWage()*0.05)*100)/100);
}
public double holidayBonus()
{
return 40*getWage();
}
public void resetWeek()
{
hoursWorked=0;
}
Override
public String toString() {
super.toString();
System.out.println("Wage: "+getWage());
System.out.println("Hours Worked: "+getHoursWorked());
return " ";
}
}
__________________________________________________________________________
package employeeType.subTypes;
import employeeType.employee.Employee;
public class SalaryEmployee extends Employee {
private double salary;
public SalaryEmployee(String firstName, String lastName,
char middleInitial, char gender, int employeeNum, boolean fulltime,double salary) {
super(firstName, lastName, middleInitial, gender, employeeNum, fulltime);
setSalary(salary);
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public double calculateWeeklyPay()
{
return getSalary()/52;
}
public void annualRaise()
{
salary=getSalary()+(Math.round((getSalary()*0.06)*100)/100);
}
public double holidayBonus()
{
return getSalary()*0.03;
}
public void resetWeek()
{
}
Override
public String toString() {
super.toString();
System.out.println("Salary: "+getSalary());
return " ";
}
}
________________________________________________________________________
package employeeType.subTypes;
import employeeType.employee.Employee;
public class CommissionEmployee extends Employee {
private double sales;
private double rate;
public CommissionEmployee(String firstName, String lastName,
char middleInitial, char gender,int employeeNum ,boolean fulltime ,double rate) {
super(firstName, lastName, middleInitial, gender, employeeNum, fulltime);
setSales(rate);
setSales(0.0);
}
public double getSales() {
return sales;
}
public void setSales(double sales) {
this.sales = sales;
}
public double getRate() {
return rate;
}
public void setRate(double rate) {
this.rate = rate;
}
public void increaseSales(double sales)
{
if(sales<0)
throw new IllegalArgumentException("Sales Must be greater than 0");
else
sales=getSales()+sales;
}
public double calculateWeeklyPay()
{
return getRate();
}
public void annualRaise()
{
rate=(getRate()+0.02);
}
public double holidayBonus()
{
return 0.0;
}
public void resetWeek()
{
setSales(0.0);
}
Override
public String toString() {
super.toString();
System.out.println("Rate: "+getRate());
System.out.println("Sales: "+getSales());
return " ";
}
}
__________________________________________________________________________
package employeeType.employee;
import employeeType.subTypes.HourlyEmployee;
import employeeType.subTypes.SalaryEmployee;
import employeeType.subTypes.CommissionEmployee;
import java.util.Scanner;
public class EmployeeTest
{
public static void main(String args[])
{
//Create references for our objects
HourlyEmployee hourly;
SalaryEmployee salary;
CommissionEmployee commission;
//The sum of all bonuses will be placed here
double bonusPayout = 0;
//Create and print a new HourlyEmployee
hourly = HourlyFactory();
System.out.printf(" %s ", hourly);
//Create and print a new SalaryEmployee
salary = SalaryFactory();
System.out.printf(" %s ", salary);
//Create and print a new CommissionEmployee
commission = CommissionFactory();
System.out.printf(" %s ", commission);
//Alter some values of Hourly and Commission
System.out.println("Increasing Hourly's hours worked by 50.");
hourly.increaseHours(50);
System.out.println("Increasing Commissions's sales by 150,000. ");
commission.increaseSales(150000);
//Output weekly pay for each Employee
System.out.printf("Hourly Payout: %.2f ", hourly.calculateWeeklyPay());
System.out.printf("Salary Payout: %.2f ", salary.calculateWeeklyPay());
System.out.printf("Commission Payout: %.2f  ", commission.calculateWeeklyPay());
//Find total bonus payout
System.out.println("Finding total bonus payout...");
bonusPayout += hourly.holidayBonus();
bonusPayout += salary.holidayBonus();
bonusPayout += commission.holidayBonus();
System.out.printf("Bonus Payout is %.2f  ", bonusPayout);
//Reset the week and apply raises to all Employees
System.out.println("Applying annual raises and resetting week...");
hourly.resetWeek();
hourly.annualRaise();
salary.resetWeek();
salary.annualRaise();
commission.resetWeek();
commission.annualRaise();
//Output Employees after changes
System.out.printf("%s %s %s ", hourly, salary, commission);
}
//Retrieve input and create HourlyEmployee
public static HourlyEmployee HourlyFactory()
{
System.out.println("Creating HourlyEmployee...");
return new HourlyEmployee("Steve", "Rogers", 'A', 'M', 12345, true, 15.34);
}
//Retrieve input and create SalaryEmployee
public static SalaryEmployee SalaryFactory()
{
System.out.println("Creating SalaryEmployee...");
return new SalaryEmployee("Kitty", "Pryde", 'X', 'F', 54321, true, 75000);
}
//Retrieve input and create CommissionEmployee
public static CommissionEmployee CommissionFactory()
{
System.out.println("Creating CommissionEmployee...");
return new CommissionEmployee("Johnny", "Storm", 'F', 'L', 976499, false, 2.5);
}
}
________________________________________________________________________

More Related Content

Similar to package employeeType.employee;public class Employee {    private.pdf

Code Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfCode Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfankitmobileshop235
 
JAVA.Q4 Create a Time class. This class will represent a point in.pdf
JAVA.Q4 Create a Time class. This class will represent a point in.pdfJAVA.Q4 Create a Time class. This class will represent a point in.pdf
JAVA.Q4 Create a Time class. This class will represent a point in.pdfkarymadelaneyrenne19
 
Program.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfProgram.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfanandshingavi23
 
maJavaProjectFinalExam.classpathmaJavaProjectFinalExam.p.docx
maJavaProjectFinalExam.classpathmaJavaProjectFinalExam.p.docxmaJavaProjectFinalExam.classpathmaJavaProjectFinalExam.p.docx
maJavaProjectFinalExam.classpathmaJavaProjectFinalExam.p.docxinfantsuk
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdffatoryoutlets
 
operating system ubuntu,Linux,Macpublic class SuperMarket {   .pdf
operating system ubuntu,Linux,Macpublic class SuperMarket {   .pdfoperating system ubuntu,Linux,Macpublic class SuperMarket {   .pdf
operating system ubuntu,Linux,Macpublic class SuperMarket {   .pdfarasanmobiles
 
ES6 patterns in the wild
ES6 patterns in the wildES6 patterns in the wild
ES6 patterns in the wildJoe Morgan
 
Creating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdfCreating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdfShaiAlmog1
 
Advanced Java - Practical File
Advanced Java - Practical FileAdvanced Java - Practical File
Advanced Java - Practical FileFahad Shaikh
 
Hi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfHi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdffashioncollection2
 
Creating a Facebook Clone - Part XI.pdf
Creating a Facebook Clone - Part XI.pdfCreating a Facebook Clone - Part XI.pdf
Creating a Facebook Clone - Part XI.pdfShaiAlmog1
 
Create a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdfCreate a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdffeelingspaldi
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
import java.util.Random;defines the Stock class public class S.pdf
import java.util.Random;defines the Stock class public class S.pdfimport java.util.Random;defines the Stock class public class S.pdf
import java.util.Random;defines the Stock class public class S.pdfaquazac
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEDarwin Durand
 
Symfony (Unit, Functional) Testing.
Symfony (Unit, Functional) Testing.Symfony (Unit, Functional) Testing.
Symfony (Unit, Functional) Testing.Basel Issmail
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBtdc-globalcode
 

Similar to package employeeType.employee;public class Employee {    private.pdf (20)

Code Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdfCode Include libraries. import javax.swing.JOptionPane;.pdf
Code Include libraries. import javax.swing.JOptionPane;.pdf
 
JAVA.Q4 Create a Time class. This class will represent a point in.pdf
JAVA.Q4 Create a Time class. This class will represent a point in.pdfJAVA.Q4 Create a Time class. This class will represent a point in.pdf
JAVA.Q4 Create a Time class. This class will represent a point in.pdf
 
Program.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdfProgram.cs class Program { static void Main(string[] args).pdf
Program.cs class Program { static void Main(string[] args).pdf
 
maJavaProjectFinalExam.classpathmaJavaProjectFinalExam.p.docx
maJavaProjectFinalExam.classpathmaJavaProjectFinalExam.p.docxmaJavaProjectFinalExam.classpathmaJavaProjectFinalExam.p.docx
maJavaProjectFinalExam.classpathmaJavaProjectFinalExam.p.docx
 
HELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdfHELP IN JAVACreate a main method and use these input files to tes.pdf
HELP IN JAVACreate a main method and use these input files to tes.pdf
 
operating system ubuntu,Linux,Macpublic class SuperMarket {   .pdf
operating system ubuntu,Linux,Macpublic class SuperMarket {   .pdfoperating system ubuntu,Linux,Macpublic class SuperMarket {   .pdf
operating system ubuntu,Linux,Macpublic class SuperMarket {   .pdf
 
ES6 patterns in the wild
ES6 patterns in the wildES6 patterns in the wild
ES6 patterns in the wild
 
Creating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdfCreating a Facebook Clone - Part XLVI - Transcript.pdf
Creating a Facebook Clone - Part XLVI - Transcript.pdf
 
Oop lecture9
Oop lecture9Oop lecture9
Oop lecture9
 
Advanced Java - Practical File
Advanced Java - Practical FileAdvanced Java - Practical File
Advanced Java - Practical File
 
Hi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdfHi, I need help with a java programming project. specifically practi.pdf
Hi, I need help with a java programming project. specifically practi.pdf
 
Creating a Facebook Clone - Part XI.pdf
Creating a Facebook Clone - Part XI.pdfCreating a Facebook Clone - Part XI.pdf
Creating a Facebook Clone - Part XI.pdf
 
Create a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdfCreate a C# applicationYou are to create a class object called “Em.pdf
Create a C# applicationYou are to create a class object called “Em.pdf
 
Manual tecnic sergi_subirats
Manual tecnic sergi_subiratsManual tecnic sergi_subirats
Manual tecnic sergi_subirats
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
import java.util.Random;defines the Stock class public class S.pdf
import java.util.Random;defines the Stock class public class S.pdfimport java.util.Random;defines the Stock class public class S.pdf
import java.util.Random;defines the Stock class public class S.pdf
 
VISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLEVISUALIZAR REGISTROS EN UN JTABLE
VISUALIZAR REGISTROS EN UN JTABLE
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Symfony (Unit, Functional) Testing.
Symfony (Unit, Functional) Testing.Symfony (Unit, Functional) Testing.
Symfony (Unit, Functional) Testing.
 
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDBTDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
TDC2016POA | Trilha .NET - CQRS e ES na prática com RavenDB
 

More from sharnapiyush773

“According to new research in the Journal of Research in Personality.pdf
“According to new research in the Journal of Research in Personality.pdf“According to new research in the Journal of Research in Personality.pdf
“According to new research in the Journal of Research in Personality.pdfsharnapiyush773
 
Trueas each officer has fixed paroleelesratio = no of parollesn.pdf
Trueas each officer has fixed paroleelesratio = no of parollesn.pdfTrueas each officer has fixed paroleelesratio = no of parollesn.pdf
Trueas each officer has fixed paroleelesratio = no of parollesn.pdfsharnapiyush773
 
to upperSolutionto upper.pdf
to upperSolutionto upper.pdfto upperSolutionto upper.pdf
to upperSolutionto upper.pdfsharnapiyush773
 
there are several theory on defining acid and base, Lewis acids and .pdf
there are several theory on defining acid and base, Lewis acids and .pdfthere are several theory on defining acid and base, Lewis acids and .pdf
there are several theory on defining acid and base, Lewis acids and .pdfsharnapiyush773
 
The Statement is False. As there are many applications of hyperbo;ic.pdf
The Statement is False. As there are many applications of hyperbo;ic.pdfThe Statement is False. As there are many applications of hyperbo;ic.pdf
The Statement is False. As there are many applications of hyperbo;ic.pdfsharnapiyush773
 
The Sarbanes-Oxley , 2002 contains following provisions which determ.pdf
The Sarbanes-Oxley , 2002 contains following provisions which determ.pdfThe Sarbanes-Oxley , 2002 contains following provisions which determ.pdf
The Sarbanes-Oxley , 2002 contains following provisions which determ.pdfsharnapiyush773
 
The main motivation behind software reuse is to avoid wastage of tim.pdf
The main motivation behind software reuse is to avoid wastage of tim.pdfThe main motivation behind software reuse is to avoid wastage of tim.pdf
The main motivation behind software reuse is to avoid wastage of tim.pdfsharnapiyush773
 
The expression evaluation is compiler dependent, and may vary. A g.pdf
The expression evaluation is compiler dependent, and may vary. A g.pdfThe expression evaluation is compiler dependent, and may vary. A g.pdf
The expression evaluation is compiler dependent, and may vary. A g.pdfsharnapiyush773
 
public class Storm {   Attributes    private String stormName;.pdf
public class Storm {   Attributes    private String stormName;.pdfpublic class Storm {   Attributes    private String stormName;.pdf
public class Storm {   Attributes    private String stormName;.pdfsharnapiyush773
 
picture is missingSolutionpicture is missing.pdf
picture is missingSolutionpicture is missing.pdfpicture is missingSolutionpicture is missing.pdf
picture is missingSolutionpicture is missing.pdfsharnapiyush773
 
OSI (Open Systems Interconnection) is reference model for how applic.pdf
OSI (Open Systems Interconnection) is reference model for how applic.pdfOSI (Open Systems Interconnection) is reference model for how applic.pdf
OSI (Open Systems Interconnection) is reference model for how applic.pdfsharnapiyush773
 
Note Modified codecode#includeiostream #include stdio.h.pdf
Note Modified codecode#includeiostream #include stdio.h.pdfNote Modified codecode#includeiostream #include stdio.h.pdf
Note Modified codecode#includeiostream #include stdio.h.pdfsharnapiyush773
 
Oligotrophic area Usually, an olidgotropic organism is a one that .pdf
Oligotrophic area Usually, an olidgotropic organism is a one that .pdfOligotrophic area Usually, an olidgotropic organism is a one that .pdf
Oligotrophic area Usually, an olidgotropic organism is a one that .pdfsharnapiyush773
 
n = N 2^(rt)n = no of people at a given timeN = initial populat.pdf
n = N 2^(rt)n = no of people at a given timeN = initial populat.pdfn = N 2^(rt)n = no of people at a given timeN = initial populat.pdf
n = N 2^(rt)n = no of people at a given timeN = initial populat.pdfsharnapiyush773
 
Maroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdf
Maroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdfMaroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdf
Maroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdfsharnapiyush773
 
It lacks the origin of replication which is most important for the i.pdf
It lacks the origin of replication which is most important for the i.pdfIt lacks the origin of replication which is most important for the i.pdf
It lacks the origin of replication which is most important for the i.pdfsharnapiyush773
 
In developmental biology, an embryo is divided into two hemispheres.pdf
In developmental biology, an embryo is divided into two hemispheres.pdfIn developmental biology, an embryo is divided into two hemispheres.pdf
In developmental biology, an embryo is divided into two hemispheres.pdfsharnapiyush773
 
Bryophytes- Development of primitive vasculature for water transport.pdf
Bryophytes- Development of primitive vasculature for water transport.pdfBryophytes- Development of primitive vasculature for water transport.pdf
Bryophytes- Development of primitive vasculature for water transport.pdfsharnapiyush773
 
Ethernet II framing (also known as DIX Ethernet, named after DEC, In.pdf
Ethernet II framing (also known as DIX Ethernet, named after DEC, In.pdfEthernet II framing (also known as DIX Ethernet, named after DEC, In.pdf
Ethernet II framing (also known as DIX Ethernet, named after DEC, In.pdfsharnapiyush773
 

More from sharnapiyush773 (20)

“According to new research in the Journal of Research in Personality.pdf
“According to new research in the Journal of Research in Personality.pdf“According to new research in the Journal of Research in Personality.pdf
“According to new research in the Journal of Research in Personality.pdf
 
Trueas each officer has fixed paroleelesratio = no of parollesn.pdf
Trueas each officer has fixed paroleelesratio = no of parollesn.pdfTrueas each officer has fixed paroleelesratio = no of parollesn.pdf
Trueas each officer has fixed paroleelesratio = no of parollesn.pdf
 
to upperSolutionto upper.pdf
to upperSolutionto upper.pdfto upperSolutionto upper.pdf
to upperSolutionto upper.pdf
 
there are several theory on defining acid and base, Lewis acids and .pdf
there are several theory on defining acid and base, Lewis acids and .pdfthere are several theory on defining acid and base, Lewis acids and .pdf
there are several theory on defining acid and base, Lewis acids and .pdf
 
The Statement is False. As there are many applications of hyperbo;ic.pdf
The Statement is False. As there are many applications of hyperbo;ic.pdfThe Statement is False. As there are many applications of hyperbo;ic.pdf
The Statement is False. As there are many applications of hyperbo;ic.pdf
 
The Sarbanes-Oxley , 2002 contains following provisions which determ.pdf
The Sarbanes-Oxley , 2002 contains following provisions which determ.pdfThe Sarbanes-Oxley , 2002 contains following provisions which determ.pdf
The Sarbanes-Oxley , 2002 contains following provisions which determ.pdf
 
The main motivation behind software reuse is to avoid wastage of tim.pdf
The main motivation behind software reuse is to avoid wastage of tim.pdfThe main motivation behind software reuse is to avoid wastage of tim.pdf
The main motivation behind software reuse is to avoid wastage of tim.pdf
 
The expression evaluation is compiler dependent, and may vary. A g.pdf
The expression evaluation is compiler dependent, and may vary. A g.pdfThe expression evaluation is compiler dependent, and may vary. A g.pdf
The expression evaluation is compiler dependent, and may vary. A g.pdf
 
public class Storm {   Attributes    private String stormName;.pdf
public class Storm {   Attributes    private String stormName;.pdfpublic class Storm {   Attributes    private String stormName;.pdf
public class Storm {   Attributes    private String stormName;.pdf
 
picture is missingSolutionpicture is missing.pdf
picture is missingSolutionpicture is missing.pdfpicture is missingSolutionpicture is missing.pdf
picture is missingSolutionpicture is missing.pdf
 
OSI (Open Systems Interconnection) is reference model for how applic.pdf
OSI (Open Systems Interconnection) is reference model for how applic.pdfOSI (Open Systems Interconnection) is reference model for how applic.pdf
OSI (Open Systems Interconnection) is reference model for how applic.pdf
 
Note Modified codecode#includeiostream #include stdio.h.pdf
Note Modified codecode#includeiostream #include stdio.h.pdfNote Modified codecode#includeiostream #include stdio.h.pdf
Note Modified codecode#includeiostream #include stdio.h.pdf
 
Oligotrophic area Usually, an olidgotropic organism is a one that .pdf
Oligotrophic area Usually, an olidgotropic organism is a one that .pdfOligotrophic area Usually, an olidgotropic organism is a one that .pdf
Oligotrophic area Usually, an olidgotropic organism is a one that .pdf
 
n = N 2^(rt)n = no of people at a given timeN = initial populat.pdf
n = N 2^(rt)n = no of people at a given timeN = initial populat.pdfn = N 2^(rt)n = no of people at a given timeN = initial populat.pdf
n = N 2^(rt)n = no of people at a given timeN = initial populat.pdf
 
Maroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdf
Maroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdfMaroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdf
Maroochy Shire Sewage Spill Case Study Student’s Name Institution Af.pdf
 
It lacks the origin of replication which is most important for the i.pdf
It lacks the origin of replication which is most important for the i.pdfIt lacks the origin of replication which is most important for the i.pdf
It lacks the origin of replication which is most important for the i.pdf
 
In developmental biology, an embryo is divided into two hemispheres.pdf
In developmental biology, an embryo is divided into two hemispheres.pdfIn developmental biology, an embryo is divided into two hemispheres.pdf
In developmental biology, an embryo is divided into two hemispheres.pdf
 
Bryophytes- Development of primitive vasculature for water transport.pdf
Bryophytes- Development of primitive vasculature for water transport.pdfBryophytes- Development of primitive vasculature for water transport.pdf
Bryophytes- Development of primitive vasculature for water transport.pdf
 
givenSolutiongiven.pdf
givenSolutiongiven.pdfgivenSolutiongiven.pdf
givenSolutiongiven.pdf
 
Ethernet II framing (also known as DIX Ethernet, named after DEC, In.pdf
Ethernet II framing (also known as DIX Ethernet, named after DEC, In.pdfEthernet II framing (also known as DIX Ethernet, named after DEC, In.pdf
Ethernet II framing (also known as DIX Ethernet, named after DEC, In.pdf
 

Recently uploaded

Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 

Recently uploaded (20)

Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 

package employeeType.employee;public class Employee {    private.pdf

  • 1. package employeeType.employee; public class Employee { private String firstName; private String lastName; private char middleInitial; private boolean fulltime; private char gender; private int employeeNum; public Employee(String firstName, String lastName, char middleInitial,char gender,int employeeNum,boolean fulltime ) { setFirstName(firstName); setLastName(lastName); setMiddleInitial(middleInitial); setFulltime(fulltime); setGender(gender); setEmployeeNum(employeeNum); } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public char getMiddleInitial() { return middleInitial; } public void setMiddleInitial(char middleInitial) {
  • 2. this.middleInitial = middleInitial; } public boolean isFulltime() { return fulltime; } public void setFulltime(boolean fulltime) { this.fulltime = fulltime; } public char getGender() { return gender; } public void setGender(char gender) { if(gender=='M' || gender=='F') { this.gender = gender; } else { this.gender='F'; } } public int getEmployeeNum() { return employeeNum; } public void setEmployeeNum(int employeeNum) { while(true) { if(employeeNum>=10000 && employeeNum<=99999) { this.employeeNum = employeeNum; } else { new IllegalArgumentException("Invalid Employee Num.should be between 10000 and 99999(inclusive) "); continue;
  • 3. } } } Override(Have to keep at the rate symbol before the override where ever it is in this project) public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Employee other = (Employee) obj; if (employeeNum != other.employeeNum) return false; if (firstName == null) { if (other.firstName != null) return false; } else if (!firstName.equals(other.firstName)) return false; if (fulltime != other.fulltime) return false; if (gender != other.gender) return false; if (lastName == null) { if (other.lastName != null) return false; } else if (!lastName.equals(other.lastName)) return false; if (middleInitial != other.middleInitial) return false; return true; } Override public String toString() {
  • 4. System.out.println(getEmployeeNum()); System.out.println(getFirstName()+", "+getLastName()+" "+getMiddleInitial()); System.out.println("Gender: "+getGender()); if(isFulltime()) { System.out.println("Status: Full Time"); } else { System.out.println("Status: Part Time"); } return " "; } } _____________________________________________________________________ package employeeType.subTypes; import employeeType.employee.Employee; public class HourlyEmployee extends Employee { private double wage; private double hoursWorked; public HourlyEmployee(String firstName, String lastName, char middleInitial, char gender,int employeeNum ,boolean fulltime ,double wage) { super(firstName, lastName, middleInitial, gender, employeeNum, fulltime); setWage(wage); setHoursWorked(0.0); } public double getWage() {
  • 5. return wage; } public void setWage(double wage) { this.wage = wage; } public double getHoursWorked() { return hoursWorked; } public void setHoursWorked(double hoursWorked) { this.hoursWorked = hoursWorked; } public void increaseHours(double hours) { if(hours>0) hoursWorked=hoursWorked+hours; else throw new IllegalArgumentException("Hours Should be Greater than 0"); } public double calculateWeeklyPay() { double pay=0.0; if(getHoursWorked()<=40) pay= getHoursWorked()*getWage(); else if(getHoursWorked()>40) pay= 40*getWage()+(getHoursWorked()-40)*2*getWage(); return pay; } public void annualRaise() {
  • 6. wage=getWage()+(Math.round((getWage()*0.05)*100)/100); } public double holidayBonus() { return 40*getWage(); } public void resetWeek() { hoursWorked=0; } Override public String toString() { super.toString(); System.out.println("Wage: "+getWage()); System.out.println("Hours Worked: "+getHoursWorked()); return " "; } } __________________________________________________________________________ package employeeType.subTypes; import employeeType.employee.Employee; public class SalaryEmployee extends Employee { private double salary; public SalaryEmployee(String firstName, String lastName, char middleInitial, char gender, int employeeNum, boolean fulltime,double salary) { super(firstName, lastName, middleInitial, gender, employeeNum, fulltime); setSalary(salary); } public double getSalary() { return salary; } public void setSalary(double salary) {
  • 7. this.salary = salary; } public double calculateWeeklyPay() { return getSalary()/52; } public void annualRaise() { salary=getSalary()+(Math.round((getSalary()*0.06)*100)/100); } public double holidayBonus() { return getSalary()*0.03; } public void resetWeek() { } Override public String toString() { super.toString(); System.out.println("Salary: "+getSalary()); return " "; } } ________________________________________________________________________ package employeeType.subTypes; import employeeType.employee.Employee; public class CommissionEmployee extends Employee { private double sales; private double rate; public CommissionEmployee(String firstName, String lastName, char middleInitial, char gender,int employeeNum ,boolean fulltime ,double rate) { super(firstName, lastName, middleInitial, gender, employeeNum, fulltime);
  • 8. setSales(rate); setSales(0.0); } public double getSales() { return sales; } public void setSales(double sales) { this.sales = sales; } public double getRate() { return rate; } public void setRate(double rate) { this.rate = rate; } public void increaseSales(double sales) { if(sales<0) throw new IllegalArgumentException("Sales Must be greater than 0"); else sales=getSales()+sales; } public double calculateWeeklyPay() { return getRate(); } public void annualRaise() { rate=(getRate()+0.02); } public double holidayBonus() { return 0.0; } public void resetWeek() {
  • 9. setSales(0.0); } Override public String toString() { super.toString(); System.out.println("Rate: "+getRate()); System.out.println("Sales: "+getSales()); return " "; } } __________________________________________________________________________ package employeeType.employee; import employeeType.subTypes.HourlyEmployee; import employeeType.subTypes.SalaryEmployee; import employeeType.subTypes.CommissionEmployee; import java.util.Scanner; public class EmployeeTest { public static void main(String args[]) { //Create references for our objects HourlyEmployee hourly; SalaryEmployee salary; CommissionEmployee commission; //The sum of all bonuses will be placed here double bonusPayout = 0; //Create and print a new HourlyEmployee hourly = HourlyFactory(); System.out.printf(" %s ", hourly); //Create and print a new SalaryEmployee salary = SalaryFactory();
  • 10. System.out.printf(" %s ", salary); //Create and print a new CommissionEmployee commission = CommissionFactory(); System.out.printf(" %s ", commission); //Alter some values of Hourly and Commission System.out.println("Increasing Hourly's hours worked by 50."); hourly.increaseHours(50); System.out.println("Increasing Commissions's sales by 150,000. "); commission.increaseSales(150000); //Output weekly pay for each Employee System.out.printf("Hourly Payout: %.2f ", hourly.calculateWeeklyPay()); System.out.printf("Salary Payout: %.2f ", salary.calculateWeeklyPay()); System.out.printf("Commission Payout: %.2f ", commission.calculateWeeklyPay()); //Find total bonus payout System.out.println("Finding total bonus payout..."); bonusPayout += hourly.holidayBonus(); bonusPayout += salary.holidayBonus(); bonusPayout += commission.holidayBonus(); System.out.printf("Bonus Payout is %.2f ", bonusPayout); //Reset the week and apply raises to all Employees System.out.println("Applying annual raises and resetting week..."); hourly.resetWeek(); hourly.annualRaise(); salary.resetWeek(); salary.annualRaise(); commission.resetWeek(); commission.annualRaise(); //Output Employees after changes
  • 11. System.out.printf("%s %s %s ", hourly, salary, commission); } //Retrieve input and create HourlyEmployee public static HourlyEmployee HourlyFactory() { System.out.println("Creating HourlyEmployee..."); return new HourlyEmployee("Steve", "Rogers", 'A', 'M', 12345, true, 15.34); } //Retrieve input and create SalaryEmployee public static SalaryEmployee SalaryFactory() { System.out.println("Creating SalaryEmployee..."); return new SalaryEmployee("Kitty", "Pryde", 'X', 'F', 54321, true, 75000); } //Retrieve input and create CommissionEmployee public static CommissionEmployee CommissionFactory() { System.out.println("Creating CommissionEmployee..."); return new CommissionEmployee("Johnny", "Storm", 'F', 'L', 976499, false, 2.5); } } ________________________________________________________________________ Solution package employeeType.employee; public class Employee { private String firstName; private String lastName; private char middleInitial; private boolean fulltime; private char gender; private int employeeNum;
  • 12. public Employee(String firstName, String lastName, char middleInitial,char gender,int employeeNum,boolean fulltime ) { setFirstName(firstName); setLastName(lastName); setMiddleInitial(middleInitial); setFulltime(fulltime); setGender(gender); setEmployeeNum(employeeNum); } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public char getMiddleInitial() { return middleInitial; } public void setMiddleInitial(char middleInitial) { this.middleInitial = middleInitial; } public boolean isFulltime() { return fulltime; } public void setFulltime(boolean fulltime) { this.fulltime = fulltime; } public char getGender() {
  • 13. return gender; } public void setGender(char gender) { if(gender=='M' || gender=='F') { this.gender = gender; } else { this.gender='F'; } } public int getEmployeeNum() { return employeeNum; } public void setEmployeeNum(int employeeNum) { while(true) { if(employeeNum>=10000 && employeeNum<=99999) { this.employeeNum = employeeNum; } else { new IllegalArgumentException("Invalid Employee Num.should be between 10000 and 99999(inclusive) "); continue; } } } Override(Have to keep at the rate symbol before the override where ever it is in this project) public boolean equals(Object obj) { if (this == obj) return true;
  • 14. if (obj == null) return false; if (getClass() != obj.getClass()) return false; Employee other = (Employee) obj; if (employeeNum != other.employeeNum) return false; if (firstName == null) { if (other.firstName != null) return false; } else if (!firstName.equals(other.firstName)) return false; if (fulltime != other.fulltime) return false; if (gender != other.gender) return false; if (lastName == null) { if (other.lastName != null) return false; } else if (!lastName.equals(other.lastName)) return false; if (middleInitial != other.middleInitial) return false; return true; } Override public String toString() { System.out.println(getEmployeeNum()); System.out.println(getFirstName()+", "+getLastName()+" "+getMiddleInitial()); System.out.println("Gender: "+getGender()); if(isFulltime()) { System.out.println("Status: Full Time"); } else {
  • 15. System.out.println("Status: Part Time"); } return " "; } } _____________________________________________________________________ package employeeType.subTypes; import employeeType.employee.Employee; public class HourlyEmployee extends Employee { private double wage; private double hoursWorked; public HourlyEmployee(String firstName, String lastName, char middleInitial, char gender,int employeeNum ,boolean fulltime ,double wage) { super(firstName, lastName, middleInitial, gender, employeeNum, fulltime); setWage(wage); setHoursWorked(0.0); } public double getWage() { return wage; } public void setWage(double wage) { this.wage = wage; } public double getHoursWorked() { return hoursWorked;
  • 16. } public void setHoursWorked(double hoursWorked) { this.hoursWorked = hoursWorked; } public void increaseHours(double hours) { if(hours>0) hoursWorked=hoursWorked+hours; else throw new IllegalArgumentException("Hours Should be Greater than 0"); } public double calculateWeeklyPay() { double pay=0.0; if(getHoursWorked()<=40) pay= getHoursWorked()*getWage(); else if(getHoursWorked()>40) pay= 40*getWage()+(getHoursWorked()-40)*2*getWage(); return pay; } public void annualRaise() { wage=getWage()+(Math.round((getWage()*0.05)*100)/100); } public double holidayBonus() { return 40*getWage(); } public void resetWeek() { hoursWorked=0;
  • 17. } Override public String toString() { super.toString(); System.out.println("Wage: "+getWage()); System.out.println("Hours Worked: "+getHoursWorked()); return " "; } } __________________________________________________________________________ package employeeType.subTypes; import employeeType.employee.Employee; public class SalaryEmployee extends Employee { private double salary; public SalaryEmployee(String firstName, String lastName, char middleInitial, char gender, int employeeNum, boolean fulltime,double salary) { super(firstName, lastName, middleInitial, gender, employeeNum, fulltime); setSalary(salary); } public double getSalary() { return salary; } public void setSalary(double salary) { this.salary = salary; } public double calculateWeeklyPay() { return getSalary()/52; } public void annualRaise() { salary=getSalary()+(Math.round((getSalary()*0.06)*100)/100);
  • 18. } public double holidayBonus() { return getSalary()*0.03; } public void resetWeek() { } Override public String toString() { super.toString(); System.out.println("Salary: "+getSalary()); return " "; } } ________________________________________________________________________ package employeeType.subTypes; import employeeType.employee.Employee; public class CommissionEmployee extends Employee { private double sales; private double rate; public CommissionEmployee(String firstName, String lastName, char middleInitial, char gender,int employeeNum ,boolean fulltime ,double rate) { super(firstName, lastName, middleInitial, gender, employeeNum, fulltime); setSales(rate); setSales(0.0); } public double getSales() { return sales; } public void setSales(double sales) { this.sales = sales; }
  • 19. public double getRate() { return rate; } public void setRate(double rate) { this.rate = rate; } public void increaseSales(double sales) { if(sales<0) throw new IllegalArgumentException("Sales Must be greater than 0"); else sales=getSales()+sales; } public double calculateWeeklyPay() { return getRate(); } public void annualRaise() { rate=(getRate()+0.02); } public double holidayBonus() { return 0.0; } public void resetWeek() { setSales(0.0); } Override public String toString() { super.toString(); System.out.println("Rate: "+getRate()); System.out.println("Sales: "+getSales()); return " ";
  • 20. } } __________________________________________________________________________ package employeeType.employee; import employeeType.subTypes.HourlyEmployee; import employeeType.subTypes.SalaryEmployee; import employeeType.subTypes.CommissionEmployee; import java.util.Scanner; public class EmployeeTest { public static void main(String args[]) { //Create references for our objects HourlyEmployee hourly; SalaryEmployee salary; CommissionEmployee commission; //The sum of all bonuses will be placed here double bonusPayout = 0; //Create and print a new HourlyEmployee hourly = HourlyFactory(); System.out.printf(" %s ", hourly); //Create and print a new SalaryEmployee salary = SalaryFactory(); System.out.printf(" %s ", salary); //Create and print a new CommissionEmployee commission = CommissionFactory(); System.out.printf(" %s ", commission); //Alter some values of Hourly and Commission System.out.println("Increasing Hourly's hours worked by 50."); hourly.increaseHours(50);
  • 21. System.out.println("Increasing Commissions's sales by 150,000. "); commission.increaseSales(150000); //Output weekly pay for each Employee System.out.printf("Hourly Payout: %.2f ", hourly.calculateWeeklyPay()); System.out.printf("Salary Payout: %.2f ", salary.calculateWeeklyPay()); System.out.printf("Commission Payout: %.2f ", commission.calculateWeeklyPay()); //Find total bonus payout System.out.println("Finding total bonus payout..."); bonusPayout += hourly.holidayBonus(); bonusPayout += salary.holidayBonus(); bonusPayout += commission.holidayBonus(); System.out.printf("Bonus Payout is %.2f ", bonusPayout); //Reset the week and apply raises to all Employees System.out.println("Applying annual raises and resetting week..."); hourly.resetWeek(); hourly.annualRaise(); salary.resetWeek(); salary.annualRaise(); commission.resetWeek(); commission.annualRaise(); //Output Employees after changes System.out.printf("%s %s %s ", hourly, salary, commission); } //Retrieve input and create HourlyEmployee public static HourlyEmployee HourlyFactory() { System.out.println("Creating HourlyEmployee..."); return new HourlyEmployee("Steve", "Rogers", 'A', 'M', 12345, true, 15.34); }
  • 22. //Retrieve input and create SalaryEmployee public static SalaryEmployee SalaryFactory() { System.out.println("Creating SalaryEmployee..."); return new SalaryEmployee("Kitty", "Pryde", 'X', 'F', 54321, true, 75000); } //Retrieve input and create CommissionEmployee public static CommissionEmployee CommissionFactory() { System.out.println("Creating CommissionEmployee..."); return new CommissionEmployee("Johnny", "Storm", 'F', 'L', 976499, false, 2.5); } } ________________________________________________________________________