Skip to content
Snippets Groups Projects
Commit 8992bde5 authored by Daniel Shchur's avatar Daniel Shchur
Browse files

Finished Lab05

parent b8a2440e
No related branches found
No related tags found
No related merge requests found
package org.cinco.payroll; package org.cinco.payroll;
public class Employee { public abstract class Employee {
private String id;
private String lastName;
private String firstName;
private String title;
private String type;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public abstract String getType();
public void setType(String type) {
this.type = type;
}
public String getFullName() {
return this.lastName + ", " + this.firstName;
}
public abstract double getGrossIncome();
public abstract double getNetIncome();
public abstract double getTaxes();
public Employee(String id, String lastName, String firstName, String title, String type) {
super();
this.id = id;
this.lastName = lastName;
this.firstName = firstName;
this.title = title;
this.type = type;
}
} }
...@@ -19,8 +19,8 @@ public class PayrollReport { ...@@ -19,8 +19,8 @@ public class PayrollReport {
String tokens[] = line.split(";"); String tokens[] = line.split(";");
String id = tokens[1]; String id = tokens[1];
String nameTokens[] = tokens[2].split(","); String nameTokens[] = tokens[2].split(",");
String lastName = nameTokens[0]; String lastName = nameTokens[0].trim();
String firstName = nameTokens[1]; String firstName = nameTokens[1].trim();
String title = tokens[3]; String title = tokens[3];
double annualSalary = 0.0, hourlyPayRate = 0.0, hoursWorked = 0.0; double annualSalary = 0.0, hourlyPayRate = 0.0, hoursWorked = 0.0;
if(tokens.length == 6) { if(tokens.length == 6) {
...@@ -31,16 +31,17 @@ public class PayrollReport { ...@@ -31,16 +31,17 @@ public class PayrollReport {
} }
if(tokens[0].equals("E")) { if(tokens[0].equals("E")) {
e = new Employee(); //TODO: modify this e = new SalariedEmployee(id, lastName, firstName, title, tokens[0], annualSalary);
} else if(tokens[0].equals("S")) { } else if(tokens[0].equals("S")) {
e = new Employee(); //TODO: modify this e = new StaffedHourlyEmployee(id, lastName, firstName, title, tokens[0], hourlyPayRate, hoursWorked);
} else if(tokens[0].equals("T")) { } else if(tokens[0].equals("T")) {
e = new Employee(); //TODO: modify this e = new TempHourlyEmployee(id, lastName, firstName, title,tokens[0], hourlyPayRate, hoursWorked);
} }
result.add(e); result.add(e);
} }
} }
s.close();
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -54,16 +55,18 @@ public class PayrollReport { ...@@ -54,16 +55,18 @@ public class PayrollReport {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(String.format("%-8s %-20s %-10s %-30s %9s %9s %9s\n", sb.append(String.format("%-8s %-20s %-10s %-30s %10s %9s %9s\n",
"ID", "Name", "Type", "Title", "Gross", "Taxes", "Net")); "ID", "Name", "Type", "Title", "Gross", "Taxes", "Net"));
//for each employee //for each employee
for(Employee e : payroll) { for(Employee e : payroll) {
//format their information //format their information
sb.append(String.format("%-8s %-20s %-10s %-30s $%8.2f $%8.2f $%8.2f\n", sb.append(String.format("%-8s %-20s %-10s %-30s $%9.2f $%8.2f $%8.2f\n",
"TODO", "TODO", "TODO", "TODO", 0.0, 0.0, 0.0)); //TODO: replace these e.getId(), e.getFullName(), e.getType(), e.getTitle(), e.getGrossIncome(), e.getTaxes(), e.getNetIncome())); //TODO: replace these
} }
System.out.println(sb); System.out.println(sb);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment