Skip to content

Instantly share code, notes, and snippets.

@hyrmn
Created March 7, 2013 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyrmn/5110108 to your computer and use it in GitHub Desktop.
Save hyrmn/5110108 to your computer and use it in GitHub Desktop.
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