Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cse156
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel Shchur
cse156
Commits
8992bde5
Commit
8992bde5
authored
7 years ago
by
Daniel Shchur
Browse files
Options
Downloads
Patches
Plain Diff
Finished Lab05
parent
b8a2440e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lab05/src/org/cinco/payroll/Employee.java
+59
-1
59 additions, 1 deletion
lab05/src/org/cinco/payroll/Employee.java
lab05/src/org/cinco/payroll/PayrollReport.java
+12
-9
12 additions, 9 deletions
lab05/src/org/cinco/payroll/PayrollReport.java
with
71 additions
and
10 deletions
lab05/src/org/cinco/payroll/Employee.java
+
59
−
1
View file @
8992bde5
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
;
}
}
This diff is collapsed.
Click to expand it.
lab05/src/org/cinco/payroll/PayrollReport.java
+
12
−
9
View file @
8992bde5
...
...
@@ -19,8 +19,8 @@ public class PayrollReport {
String
tokens
[]
=
line
.
split
(
";"
);
String
id
=
tokens
[
1
];
String
nameTokens
[]
=
tokens
[
2
].
split
(
","
);
String
lastName
=
nameTokens
[
0
];
String
firstName
=
nameTokens
[
1
];
String
lastName
=
nameTokens
[
0
]
.
trim
()
;
String
firstName
=
nameTokens
[
1
]
.
trim
()
;
String
title
=
tokens
[
3
];
double
annualSalary
=
0.0
,
hourlyPayRate
=
0.0
,
hoursWorked
=
0.0
;
if
(
tokens
.
length
==
6
)
{
...
...
@@ -31,16 +31,17 @@ public class PayrollReport {
}
if
(
tokens
[
0
].
equals
(
"E"
))
{
e
=
new
Employee
(
);
//TODO: modify this
e
=
new
Salaried
Employee
(
id
,
lastName
,
firstName
,
title
,
tokens
[
0
],
annualSalary
);
}
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"
))
{
e
=
new
Employee
();
//TODO: modify this
e
=
new
TempHourlyEmployee
(
id
,
lastName
,
firstName
,
title
,
tokens
[
0
],
hourlyPayRate
,
hoursWorked
);
}
result
.
add
(
e
);
}
}
s
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -54,16 +55,18 @@ public class PayrollReport {
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
String
.
format
(
"%-8s %-20s %-10s %-30s %
9
s %9s %9s\n"
,
sb
.
append
(
String
.
format
(
"%-8s %-20s %-10s %-30s %
10
s %9s %9s\n"
,
"ID"
,
"Name"
,
"Type"
,
"Title"
,
"Gross"
,
"Taxes"
,
"Net"
));
//for each employee
for
(
Employee
e
:
payroll
)
{
//format their information
sb
.
append
(
String
.
format
(
"%-8s %-20s %-10s %-30s $%
8
.2f $%8.2f $%8.2f\n"
,
"TODO"
,
"TODO"
,
"TODO"
,
"TODO"
,
0.0
,
0.0
,
0.0
));
//TODO: replace these
sb
.
append
(
String
.
format
(
"%-8s %-20s %-10s %-30s $%
9
.2f $%8.2f $%8.2f\n"
,
e
.
getId
(),
e
.
getFullName
(),
e
.
getType
(),
e
.
getTitle
(),
e
.
getGrossIncome
(),
e
.
getTaxes
(),
e
.
getNetIncome
()
));
//TODO: replace these
}
System
.
out
.
println
(
sb
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment