// Program Name:
TeamRuns.java
// Course:
CSE 1302J
// Student Name:
Bradley Shedd
import
java.io.*;
import
java.text.*;
class
TeamRuns
{
public
static
void
main (String [] args)
throws
Exception
{
final
int MAX=7;
Person[] personnel =
new
Person[MAX];
personnel[0]=new
Volunteer("Bill");
personnel[1]=new
Salaried("Sue",
"111111111",
1200);
personnel[2]=new
Hourly("Amber","222222222",
10);
personnel[3]=new
UnionMember("Diego",
"333333333",
10);
personnel[4]=new
Volunteer("Trudy");
personnel[5]=new
Hourly("Joe",
"4444",
60);
personnel[6]=new
UnionMember("Tom",
"55555",
20);
((Hourly) personnel[2]).addHours(10);
((Hourly) personnel[3]).addHours(41);
((Hourly) personnel[5]).addHours(50);
((Hourly) personnel[6]).addHours(25);
double
amount;
for
(int i=0; i < personnel.length;
i++)
{
System.out.println (personnel[i]);
amount = personnel[i].pay();
if
(amount == 0.0)
System.out.println ("Thanks!");
else
System.out.println ("Paid: "
+ amount);
System.out.println ("-----------------------------------");
}
}
}
// Program Name:
Volunteer.java
// Course:
CSE 1302J
// Student Name:
Bradley Shedd
public
class Volunteer
extends
Person
{
public
Volunteer (String name)
{
super
(name);
}
public
double pay()
{
System.out.println("Thank
You ");
return
0.0;
}
}
// Program Name:
Person.java
// Course:
CSE 1302J
// Student Name:
Bradley Shedd
public
abstract
class Person
{
private String name;
public Person(String name)
{
this.name=name;
}
public String toString()
{
return
"Name:\t" + name;
}
public
abstract
double pay();
}
// Program Name:
Salaried.java
// Course:
CSE 1302J
// Student Name:
Bradley Shedd
public
class
Salaried
extends Employee
{
private
double
weeklySalary;
public Salaried (String name, String
socSecNumber,
double sal)
{
super (name, socSecNumber);
weeklySalary = sal;
}
public
double
pay()
{
return weeklySalary;
}
}
// Program Name:
Employee.java
// Course:
CSE 1302J
// Student Name: Bradley
Shedd
public
abstract
class Employee
extends
Person
{
protected String socialSecurityNumber;
public Employee (String name, String
socSecNumber)
{
super (name);
socialSecurityNumber = socSecNumber;
}
public String toString()
{
String result =
super.toString();
result +=
"\nSocial Security Number: "
+ socialSecurityNumber;
return result;
}
}
// Program Name:
Hourly.java
// Course:
CSE 1302J
// Student Name:
Bradley Shedd
public
class Hourly
extends
Employee
{
private
double hoursWorked;
private
double hourlyRate;
public
Hourly (String name, String socSecNumber,
double
rate)
{
super
(name, socSecNumber);
hoursWorked = 0.0;
hourlyRate=rate;
}
public
void addHours (double
moreHours)
{
hoursWorked += moreHours;
}
public
double pay()
{
double
payment = hourlyRate * hoursWorked;
hoursWorked = 0.0;
return
payment;
}
public
String toString()
{
String result =
super.toString();
result +=
"\nCurrent hours: " + hoursWorked;
return
result;
}
}
// Program Name:
UnionMember.java
// Course: CSE
1302J
// Student Name:
Bradley Shedd
public
class UnionMember
extends
Hourly
{
public
UnionMember (String name, String socSecNumber,
double
rate)
{
super
(name, socSecNumber, rate);
}
public
String UnionMemberR()
{
return
super.pay() +
"includes overtime with pay";
}
}