using System;
namespace Tut2
{
public abstract class Employee
{
private string _ID, _Name, _Address, _Contact;
private bool _Resident;
public string ID
{
get { return _ID; }
}
public string Name
{
get { return _Name; }
}
public string Address
{
get { return _Address; }
}
public string Contact
{
get { return _Contact; }
}
public bool Resident
{
get { return _Resident; }
}
public Employee(string id, string name, string address, string contact, bool resident)
{
_ID = id;
_Name = name;
_Address = address;
_Contact = contact;
_Resident = resident;
}
public abstract decimal Calculate(ushort hours);
public abstract decimal PayRate();
public override string ToString()
{
string status;
if (_Resident == true)
status = "Yes";
else
status = "No";
return string.Format("{0}::{1} - Resident {3}\n\tContact Details: {4} - {5}", _ID, _Name, status, _Address, _Contact);
}
}
public class Salary : Employee
{
private decimal _AnnualSalary;
public decimal AnnualSalary
{
get { return _AnnualSalary; }
}
public Salary(string id, string name, string address, string contact, bool resident, decimal salary)
: base(id, name, address, contact, resident)
{
_AnnualSalary = salary;
}
public Salary(Salary salary)
{
}
public override decimal Calculate(ushort hours)
{
}
public override decimal PayRate()
{
}
public override string ToString()
{
return string.Format("{0}\n\t Annual Salary: {1:c}", base.ToString(), _AnnualSalary);
}
}
public class Wage : Employee
{
private decimal _Rate;
public decimal Rate
{
get { return _Rate; }
}
public Wage(string id, string name, string address, string contact, bool resident, decimal rate)
: base(id, name, address, contact, resident)
{
_Rate = rate;
}
public Wage(Wage wage)
{
}
public override decimal Calculate(ushort hours)
{
}
public override decimal PayRate()
{
}
public override string ToString()
{
return string.Format("{0}\n\t Hourly Rate: {1:c}", base.ToString(), _Rate);
}
}
public class Payroll
{
private Employee _Employee;
private ushort _Hours;
public Employee Employee
{
get { return _Employee; }
}
public ushort Hours
{
get { return _Hours; }
}
public Payroll(Employee employee, ushort hours)
{
_Employee = employee;
_Hours = hours;
}
public Payroll(payroll Payroll)
{
}
public override decimal Calculate(ushort hours)
{
}
public override string ToString()
{
return string.Format("");
}
}
class Program
{
static void Main(string[] args)
{
Employee[] employee = new Employee[]
{
new Salary("S001", "John Smith", "12 Albert Street - Melbourne - Vic. 3000", "9311 1111", true, 180001m),
new Salary("S002", "Jenny Smith", "12 Albert Street - Melbourne - Vic. 3000", "93111 111", true,80001m),
new Salary("S003", "Jessica Smith", "12 Albert Street - Melbourne - Vic. 3000", "9311 1111", true,35001m),
new Salary("S004", "Tom Brown", "18/9 Spring Road - Noble Park - Vic. 3174", "9777 7777", true, 5001m),
new Salary("S005", "Katherine Zhang", "402/200 Ballarat Rd - Footscray - VIC 3011", "9344 4444", false, 27000m),
new Wage("W001", "Ben Brown", "18/9 Spring Road - Noble Park - Vic. 3174", "9777 7777", true, 17.5M),
new Wage("W002", "July Wang", "34 Smith Street - Collingwood - Vic. 3066", "9322 3231", false, 15.0M),
new Wage("W003", "Tim Garner", "603/250 Barkly St - Footscray - VIC 3011", "9321 7165", true,32.5M),
new Wage("W004", "Tod Jones", "4/27 Gordon St - Footscray - VIC 3011", "9335 7189", true, 25.0M),
new Wage("W005", "Kate Anderson", "1 Rosemary Street - Chadstone - VIC 3148", "9522 3233", true,10.0M)
};
Console.WriteLine("Employee List:\n{0}", new string('=', 40));
foreach (Employee staff in employee)
Console.WriteLine(staff + "\n");
Console.WriteLine();
Payroll[] payroll = new Payroll[]
{
new Payroll(employee[0], 38),
new Payroll(employee[1], 39),
new Payroll(employee[2], 46),
new Payroll(employee[3], 51),
new Payroll(employee[4], 20),
new Payroll(employee[4], 40),
new Payroll(employee[5], 38),
new Payroll(employee[6], 39),
new Payroll(employee[6], 46),
new Payroll(employee[7], 51),
new Payroll(employee[7], 37),
new Payroll(employee[8], 120),
new Payroll(employee[9], 10),
new Payroll(employee[9], 38)
};
Console.WriteLine("Payroll List:\n{0}", new string('=', 40));
foreach (Payroll item in payroll)
Console.WriteLine(item + "\n");
Console.WriteLine();
}
}
}
I will also attach it as a CS file.
Thank you, Bondy


Sign In
Create Account


Back to top










