You are on page 1of 3

using System;

namespace ConsoleApplication11
{
class Program
{
public static void Main(string[] args)
{
double totalwage;
Student stud = new Student ("Justin", "Miranda", -89);
Worker work = new Worker ("Krystal", "Claire", 350, 8);
totalwage = work.SolveTotalWage();

Console.WriteLine(stud.FirstName+ " " +stud.LastName+ " has a mark of "


+stud.Mark);
Console.WriteLine(work.FirstName + " " + work.LastName + " with "
+work.Wage+ " of wage worked for " + work.Hours + " hours and earned " + totalwage+
" Pesos.");
Console.ReadLine();
}
}
public class Human
{
private string first_name;
private string last_name;
public Human(string NameF, string NameL)
{
first_name = NameF;
last_name = NameL;
}
public string FirstName
{
get
{
return first_name;
}
set
{
if (value == null)
{
throw new ArgumentNullException("Can't be null");
}
else
{
first_name = value;
}
}
}
public string LastName
{
get
{
return last_name;
}
set
{
if (value == null)
{
throw new ArgumentNullException("Can't be null");
}
else
{
last_name = value;
}
}
}

}
public class Student : Human
{
private int mark;
public Student(string first_name, string last_name, int M)
:base (first_name, last_name )
{
this.mark = M;
}
public int Mark
{
get
{ return mark; }
set
{
if (value < 0)
{
Console.Write("Invalid!!");
}
else
this.mark = value;
}
}

}
public class Worker : Human
{
private int wage;
private int hours;
public Worker(string first_name, string last_name , int W, int H)
:base(first_name, last_name )
{
this.wage = W;
this.hours = H;
}

public int Wage


{
get { return wage; }
set
{
if (value <= 0)
{
throw new ArgumentException();

}
else
{
this.wage = value;
}
}
}
public int Hours
{
get
{
return hours;
}
set
{
if (value <= 0)
{
throw new ArgumentException();

}
else
{
this.hours = value;
}
}
}

public double SolveTotalWage()


{
double totalwage = wage * hours;
return totalwage;
}
}

You might also like