Exemplo n.º 1
0
 public override void Add(Person person)
 {
     if (person is HeadOfHousehold)
     {
         base.Add(person);
     }
     else
     {
         HeadOfHousehold head = Find(typeof(HeadOfHousehold)) as HeadOfHousehold;
         if (head != null)
         {
             base.Add(person);
         }
     }
 }
Exemplo n.º 2
0
    public override void Show()
    {
        foreach (Person p in people)
        {
            if (p is HeadOfHousehold)
            {
                p.Show();

                HeadOfHousehold head = p as HeadOfHousehold;
                foreach (Dependent d in head.dependents)
                {
                    d.Show();
                }
            }
        }
    }
Exemplo n.º 3
0
    static void Main(string[] args)
    {
        HeadOfHousehold mother = new HeadOfHousehold("Billy", "Jean", new DateTime(1983, 2, 1));
        Dependent       child  = new Dependent("Joe", "Jean", new DateTime(2001, 6, 1), Relationship.Child);
        Dependent       child2 = new Dependent("Bob", "Jean", new DateTime(2003, 5, 24), Relationship.Child);

        mother.Add(child);
        mother.Add(child2);
        TaxHouseHold household = new TaxHouseHold();

        household.Add(mother);
        household.Show();
        bool result = IsAwesome(mother);

        Console.WriteLine($"Is Awesome = {result}");
        Console.ReadLine(); //Wait for someone to press enter
    }