Example #1
0
        static void Composite()
        {
            var elictrician = new Electrician();

            #region mocks
            // StreetCorners
            var corner1  = new StreetCorner(1);
            var corner2  = new StreetCorner(4);
            var corner3  = new StreetCorner(2);
            var corner4  = new StreetCorner(3);
            var corner5  = new StreetCorner(2);
            var corner6  = new StreetCorner(1);
            var corner7  = new StreetCorner(3);
            var corner8  = new StreetCorner(3);
            var corner9  = new StreetCorner(5);
            var corner10 = new StreetCorner(1);

            // Streets
            var street1 = new Street(110, 10, 25);
            var street2 = new Street(100, 12, 20);
            var street3 = new Street(80, 5, 10);
            var street4 = new Street(90, 8, 30);
            var street5 = new Street(70, 2, 15);
            var street6 = new Street(115, 3, 35);
            var street7 = new Street(105, 2, 30);
            var street8 = new Street(105, 4, 20);
            var street9 = new Street(85, 4, 15);

            // Squares
            var square1 = new Square("San Martin", 36, 5, 4);
            var square2 = new Square("Italia", 36, 5, 4);
            var square3 = new Square("Lezama", 36, 5, 4);
            var square4 = new Square("Plaza de Mayo", 60, 45, 20);


            // NeighborhoodA: 9 blocks, 2 square

            // Blocks
            var block1 = new CompositePlace();
            block1.AddPlace(street1);
            block1.AddPlace(street5);
            block1.AddPlace(corner1);

            var block2 = new CompositePlace();
            block2.AddPlace(street1);
            block2.AddPlace(street5);
            block2.AddPlace(street6);
            block2.AddPlace(corner1);
            block2.AddPlace(corner2);

            var block3 = new CompositePlace();
            block3.AddPlace(street1);
            block3.AddPlace(street6);
            block3.AddPlace(street7);
            block3.AddPlace(corner2);
            block3.AddPlace(corner3);
            block3.AddPlace(square1);

            var block4 = new CompositePlace();
            block4.AddPlace(street1);
            block4.AddPlace(street2);
            block4.AddPlace(street5);
            block4.AddPlace(corner1);
            block4.AddPlace(corner6);

            var block5 = new CompositePlace();
            block5.AddPlace(street1);
            block5.AddPlace(street2);
            block5.AddPlace(street5);
            block5.AddPlace(street6);
            block5.AddPlace(corner1);
            block5.AddPlace(corner6);
            block5.AddPlace(corner2);
            block5.AddPlace(corner7);

            var block6 = new CompositePlace();
            block6.AddPlace(street1);
            block6.AddPlace(street2);
            block6.AddPlace(street6);
            block6.AddPlace(street7);
            block6.AddPlace(corner2);
            block6.AddPlace(corner3);
            block6.AddPlace(corner7);
            block6.AddPlace(corner8);
            block6.AddPlace(square2);

            var neighborhoodA = new CompositePlace();
            neighborhoodA.AddPlace(block1);
            neighborhoodA.AddPlace(block2);
            neighborhoodA.AddPlace(block3);

            // NeighborhoodB: 7 blocks, 1 square

            // Blocks
            block1 = new CompositePlace();
            block1.AddPlace(street1);
            block1.AddPlace(street8);
            block1.AddPlace(corner4);

            block2 = new CompositePlace();
            block2.AddPlace(street1);
            block2.AddPlace(street8);
            block2.AddPlace(street9);
            block2.AddPlace(corner4);
            block2.AddPlace(corner5);

            block3 = new CompositePlace();
            block3.AddPlace(street1);
            block3.AddPlace(street2);
            block3.AddPlace(street8);
            block3.AddPlace(corner4);
            block3.AddPlace(corner9);
            block3.AddPlace(square3);

            block4 = new CompositePlace();
            block4.AddPlace(street1);
            block4.AddPlace(street2);
            block4.AddPlace(street8);
            block4.AddPlace(street9);
            block4.AddPlace(corner4);
            block4.AddPlace(corner5);
            block4.AddPlace(corner9);
            block4.AddPlace(corner10);
            block4.AddPlace(square4);

            var neighborhoodB = new CompositePlace();
            neighborhoodA.AddPlace(block1);
            neighborhoodA.AddPlace(block2);
            neighborhoodA.AddPlace(block3);
            neighborhoodA.AddPlace(block4);

            // NeighborhoodC: 5 blocks, 2 square
            var neighborhoodC = new CompositePlace();

            // NeighborhoodD: 6 blocks
            var neighborhoodD = new CompositePlace();

            var city = new CompositePlace();
            city.AddPlace(neighborhoodA);
            city.AddPlace(neighborhoodB);
            #endregion mocks

            elictrician.changeBurntLamps(city);
        }
Example #2
0
        private static void SeedData(IList <IEmployee> employees)
        {
            ChiefExecutiveOfficer chiefExecutiveOfficer = new ChiefExecutiveOfficer();

            chiefExecutiveOfficer.Id                   = 1;
            chiefExecutiveOfficer.JobTitle             = "CEO";
            chiefExecutiveOfficer.FirstName            = "James";
            chiefExecutiveOfficer.LastName             = "Jenkins";
            chiefExecutiveOfficer.AnnualSalary         = 200000;
            chiefExecutiveOfficer.HighestQualification = "Masters Degree";
            chiefExecutiveOfficer.Gender               = 'm';
            chiefExecutiveOfficer.OfficeId             = "E120";
            chiefExecutiveOfficer.JoinDate             = new DateTime(2018, 1, 12);
            chiefExecutiveOfficer.SecretaryId          = 43;
            chiefExecutiveOfficer.PersonalAssistant    = 102;

            employees.Add(chiefExecutiveOfficer);

            Manager projectManager = new ProjectManager();

            projectManager.Id                   = 2;
            projectManager.JobTitle             = "Project Manager";
            projectManager.FirstName            = "Bob";
            projectManager.LastName             = "Jones";
            projectManager.AnnualSalary         = 100000;
            projectManager.HighestQualification = "Honours Degree";
            projectManager.Gender               = 'm';
            projectManager.OfficeId             = "D017";
            projectManager.JoinDate             = new DateTime(2015, 4, 1);
            projectManager.SecretaryId          = 110;
            projectManager.Id                   = 2;

            employees.Add(projectManager);

            Manager safetyManager = new SafetyManager();

            safetyManager.Id                   = 3;
            safetyManager.JobTitle             = "Safety Manager";
            safetyManager.FirstName            = "Jane";
            safetyManager.LastName             = "Summers";
            safetyManager.AnnualSalary         = 100000;
            safetyManager.HighestQualification = "Honours Degree";
            safetyManager.Gender               = 'f';
            safetyManager.OfficeId             = "D018";
            safetyManager.JoinDate             = new DateTime(2016, 2, 3);
            safetyManager.SecretaryId          = 145;

            employees.Add(safetyManager);

            Employee craneOperator = new CraneOperator();

            craneOperator.Id                   = 4;
            craneOperator.JobTitle             = "Crane Operator";
            craneOperator.FirstName            = "Sam";
            craneOperator.LastName             = "Drake";
            craneOperator.AnnualSalary         = 50000;
            craneOperator.HighestQualification = "Bachelor's Degree";
            craneOperator.Gender               = 'm';
            craneOperator.JoinDate             = new DateTime(2012, 5, 7);

            employees.Add(craneOperator);

            Employee electrician = new Electrician();

            electrician.Id                   = 5;
            electrician.JobTitle             = "Electrician";
            electrician.FirstName            = "James";
            electrician.LastName             = "Ross";
            electrician.AnnualSalary         = 45000;
            electrician.HighestQualification = "Bachelor's Degree";
            electrician.Gender               = 'm';
            electrician.JoinDate             = new DateTime(2013, 1, 16);

            employees.Add(electrician);

            Employee electrician2 = new Electrician();

            electrician2.Id                   = 6;
            electrician2.JobTitle             = "Electrician";
            electrician2.FirstName            = "Henry";
            electrician2.LastName             = "Sanders";
            electrician2.AnnualSalary         = 45000;
            electrician2.HighestQualification = "Bachelor's Degree";
            electrician2.Gender               = 'm';
            electrician2.JoinDate             = new DateTime(2017, 1, 16);

            employees.Add(electrician2);
        }
Example #3
0
        static void ChainOfResponsability()
        {
            var A = new House(100, 25, 4);
            var B = new House(102, 16, 1);
            var C = new House(104, 34, 5);
            var D = new House(106, 20, 3);
            var E = new House(108, 9, 2);
            var F = new House(109, 25, 4);
            var G = new Square("G", 16, 2, 5);
            var H = new Square("H", 16, 2, 5);
            var I = new Square("I", 16, 2, 5);
            var J = new Square("J", 36, 5, 4);

            var street = new Street(110, 64, 25);

            A.Street = street;
            B.Street = street;
            C.Street = street;
            D.Street = street;
            E.Street = street;
            F.Street = street;
            G.Street = street;
            H.Street = street;
            I.Street = street;
            J.Street = street;

            G.Builder = new mixedBuilder();
            H.Builder = new FavorableBuilder();
            I.Builder = new UnfavorableBuilder();

            // WHATSAPP
            WhatsAppMessage whatsAppList = null;

            whatsAppList = new WhatsAppMessage(new FireReport(G), whatsAppList);
            whatsAppList = new WhatsAppMessage(new FireReport(H), whatsAppList);
            whatsAppList = new WhatsAppMessage(new FireReport(I), whatsAppList);

            // HEART ATTACK - 2
            var passerbyReport = new HearthAttackReport();

            passerbyReport.Pedestrian = new Passerby();
            whatsAppList = new WhatsAppMessage(passerbyReport, whatsAppList);

            var foreignPasserbyReport = new HearthAttackReport();
            var passerbyAddapter      = new ForeignPasserbyAdapter(new ForeignPasserby(pc: 0.20, pb: 0.30, phr: 0.50));

            foreignPasserbyReport.Pedestrian = passerbyAddapter;
            whatsAppList = new WhatsAppMessage(foreignPasserbyReport, whatsAppList);

            // ROBBERY - 3
            var robbertyReport1 = new RobberyReport();

            robbertyReport1.Place = A;
            whatsAppList          = new WhatsAppMessage(robbertyReport1, whatsAppList);

            var robbertyReport2 = new RobberyReport();

            robbertyReport2.Place = B;
            whatsAppList          = new WhatsAppMessage(robbertyReport2, whatsAppList);

            var robbertyReport3 = new RobberyReport();

            robbertyReport3.Place = J;
            whatsAppList          = new WhatsAppMessage(robbertyReport3, whatsAppList);

            // BURNT LAMPS - 5
            var burntReport1 = new BurntLampReport();

            burntReport1.Place = street;
            whatsAppList       = new WhatsAppMessage(burntReport1, whatsAppList);

            var burntReport2 = new BurntLampReport();

            burntReport2.Place = street;
            whatsAppList       = new WhatsAppMessage(burntReport2, whatsAppList);

            var burntReport3 = new BurntLampReport();

            burntReport3.Place = street;
            whatsAppList       = new WhatsAppMessage(burntReport3, whatsAppList);

            var burntReport4 = new BurntLampReport();

            burntReport4.Place = street;
            whatsAppList       = new WhatsAppMessage(burntReport4, whatsAppList);

            var burntReport5 = new BurntLampReport();

            burntReport5.Place = street;
            whatsAppList       = new WhatsAppMessage(burntReport5, whatsAppList);

            var complaintsByWhatsapp = new ComplaintByWhatsapp(whatsAppList);

            // TEST
            CompliantHandler handler = new Medic(new RCPTypeA());

            handler = new Firefighter(handler);
            handler = new Electrician(handler);
            handler = new Cop(new RequestBackup(), handler);

            var operator911 = new Operator911(handler);

            operator911.AttendReport(complaintsByWhatsapp);
        }