Example #1
0
        public void PatternImplementation()
        {
            HourlyEmployee   hourlyEmployee   = new HourlyEmployee("1429", "John Doe", 32, 50);
            SalariedEmployee salariedEmployee = new SalariedEmployee("1532", "James Cole", 50, 3000);
            List <IEmployee> employees        = new List <IEmployee> {
                hourlyEmployee, salariedEmployee
            };

            SalaryReportGenerationVisitor reportGeneration = new SalaryReportGenerationVisitor();

            foreach (IEmployee employee in employees)
            {
                employee.Accept(reportGeneration);
            }

            Console.WriteLine(reportGeneration.ReportContent.ToString());
        }
Example #2
0
 public void VisitHourlyEmployee(HourlyEmployee hourlyEmployee)
 {
     ReportContent.AppendLine($"{hourlyEmployee.Id,-10} | {hourlyEmployee.Name,-10} | {hourlyEmployee.Hours,-10} | {hourlyEmployee.Hours * hourlyEmployee.PerHour,-10}, | {"low", -10}");
 }