Created
March 7, 2013 17:49
-
-
Save hyrmn/5110108 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace ConsoleApplication8 | |
{ | |
public class Person | |
{ | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
public virtual string GetDisplayName() | |
{ | |
return FirstName + " " + LastName; | |
} | |
} | |
public class Employee : Person | |
{ | |
private decimal salary = 0; | |
public decimal Salary | |
{ | |
get | |
{ | |
return salary; | |
} | |
} | |
public void GiveRaise(decimal raise) | |
{ | |
salary = salary + raise; | |
} | |
} | |
public class Manager : Employee | |
{ | |
public override string GetDisplayName() | |
{ | |
return "The Cheez - " + base.GetDisplayName(); | |
} | |
} | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var customers = new List<Person> | |
{ | |
new Person { FirstName = "Bob", LastName = "Smith" }, | |
new Person { FirstName = "Sue", LastName = "Smith" }, | |
new Person { FirstName = "Mary", LastName = "Allen" } | |
}; | |
var employees = new List<Employee> | |
{ | |
new Employee { FirstName = "Jimbo", LastName = "Jambo" }, | |
new Employee { FirstName = "Emeril", LastName = "McGravitz" } | |
}; | |
var manager = new Manager { FirstName = "Scrooge", LastName = "McDuck" }; | |
var everyone = new List<Person>(customers); | |
everyone.AddRange(employees); | |
everyone.Add(manager); | |
foreach (var person in everyone) | |
{ | |
Console.WriteLine(person.GetDisplayName()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment