package inputOutput;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* Class to produce a table of information about customers
*/
public class EmployeeTablePrinter1
{
public static void main(String[] args)
{
List<Employee1> employees = new ArrayList<Employee1>();
// Populate list with Employees
employees.add( new Employee1(1, "Bloggs, Fred", "10 Firebird Crescent",
new Date(1976 - 1900, 5 - 1, 20), 40000.00 ) );
employees.add( new Employee1(2, "Charles, Cheryl", "5 Lattice Lane",
new Date(1989 - 1900, 4 - 1, 3), 50000.00 ) );
employees.add( new Employee1(3, "Romney, Titus", "42 St. Martins Rd.",
new Date(1973 - 1900, 11 - 1, 19), 45000.00 ) );
employees.add( new Employee1(4, "Clinton, Burton", "567 Nebula Circle",
new Date(1964 - 1900, 1 - 1, 29), 100000.00 ) );
employees.add( new Employee1(5, "McDuff, Hazel", "1 Church Row",
new Date(1985 - 1900, 3 - 1, 6), 55000.00 ) );
employees.add( new Employee1(6, "Frazier, Bill", "92 S. Main St.",
new Date(1980 - 1900, 12 - 1, 5), 70000.00 ) );
employees.add( new Employee1(7, "Zambroski, Heather", "589 Trumpington Place",
new Date(1959 - 1900, 4 - 1, 3), 50000.00 ) );
// Print out the table of employees
Employee1.printHeader();
for (Employee1 emp : employees)
{
emp.print();
}
}
}
/**
* Class to represent an employee
*/
class Employee1
{
Employee1(int id, String name, String address, Date dob, double salary)
{
m_id = id;
m_name = name;
m_address = address;
m_dob = dob;
m_salary = salary;
}
static void printHeader()
{
System.out.print("|");
System.out.print("ID" + "|");
System.out.print("Name" + "|");
System.out.print("Address" + "|");
System.out.print("Date of Birth" + "|");
System.out.println("Salary" + "|"); }
void print()
{
System.out.print("|");
System.out.print(m_id + "|");
System.out.print(m_name + "|");
System.out.print(m_address + "|");
System.out.print(m_dob + "|");
System.out.println(m_salary + "|");
}
private int m_id;
private String m_name;
private String m_address;
private Date m_dob;
private double m_salary;
}
|