Mgetch/CsharpClass — pull request #8 by keegane (2014-02-13 13:47:43+00:00)
Title: Create Keegans code Homework 2

My logic is right I think. I just don't know how to do it syntactically.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication5
{
class Person
{
public void setName(string name)
{
name = ("Firstname, Lastname");
}
public void setAge(int age)
{
age = 0;
}
public void setTotalHours(int totalHours)
{
totalHours = 0;
}
public void setBasePay(int basepay)
{
basepay = 0;
}
public void setHourly(int hourlyWage)
{
hourlyWage = hourlyWage;
}
protected int age;
protected string name;
protected int totalHours;
protected int basepay;
protected int hourlyWage;

}

// Derived class
class HourlyWorker : Person
{
public int getTotalPay()
{
int totalPay = 0;
return totalPay = (basepay + hourlyWage * totalHours);
}
}
// Derived Class
class SalariedWorker : Person
{
public int getTotalPay()
{
int totalPay = 0;
return totalPay = (basepay + hourlyWage * totalHours);
}
}

class Program
{
static void Main(string[] args)
{
Person hourlyWorker = new Person();
Person salariedWorker = new Person();

hourlyWorker.setBasePay(0);
hourlyWorker.setHourly(11);
salariedWorker.setBasePay(1000);
salariedWorker.setHourly(4);

hourlyWorker.setTotalHours(1);

salariedWorker.setTotalHours(1);

for (int totalHours = 1; hourlyWorker.getTotalPay()!= salariedWorker.getTotalPay();totalHours++)
{
totalHours = totalHours;
}

// Print the area of the object.
Console.WriteLine("Total hours: {0}",(salariedWorker.totalHours));
Console.ReadKey();
}
}
}