Exemple #1
0
        static void Builder()
        {
            var fireman = new Firefighter();
            var street  = new Street(110, 64, 25);
            var street2 = new Street(110, 64, 10);

            var simpleDeco = new BasicBuilder();
            var mixedDeco  = new mixedBuilder();
            var favoDeco   = new FavorableBuilder();
            var unfavoDeco = new UnfavorableBuilder();

            var house1 = new House(101, 16, 5, mixedDeco);

            house1.Street = street;
            var house2 = new House(102, 9, 3, favoDeco);

            house2.Street = street2;
            var square1 = new Square("Plaza1", 16, 10, 2, unfavoDeco);

            square1.Street = street;
            var square2 = new Square("Plaza2", 25, 20, 10, simpleDeco);

            square2.Street = street2;

            house1.AddObserver(fireman);
            house2.AddObserver(fireman);
            square1.AddObserver(fireman);
            square2.AddObserver(fireman);

            square1.Spark();
        }
Exemple #2
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Firefighter instance = Firefighter.Instance;

            if (instance == null)
            {
                IncStat("No Service");
                return(false);
            }

            List <SimDescription> sims = new List <SimDescription>();

            foreach (SimDescription sim in Sims.All)
            {
                if (SimTypes.IsSelectable(sim))
                {
                    IncStat("Active");
                }
                else if (sim.CreatedSim == null)
                {
                    IncStat("Hibernating");
                }
                else if (sim.LotHome == null)
                {
                    IncStat("Not Resident");
                }
                else if (!(sim.Occupation is ActiveFireFighter))
                {
                    IncStat("Not Firefighter");
                }
                else if (!Situations.Allow(this, sim, Managers.Manager.AllowCheck.None))
                {
                    IncStat("Situation Denied");
                }
                else
                {
                    sims.Add(sim);
                }
            }

            if (sims.Count > 0)
            {
                AddStat("Choices", sims.Count);

                SimDescription choice = RandomUtil.GetRandomObjectFromList(sims);

                if (Situations.GreetSimOnLot(choice, Lot))
                {
                    IncStat("Active Firefighter");

                    new NRaas.StoryProgressionSpace.Situations.FirefighterSituation(Lot, choice.CreatedSim);
                    return(true);
                }
            }

            IncStat("Service Firefighter");

            instance.MakeServiceRequest(Lot, true, ObjectGuid.InvalidObjectGuid);
            return(true);
        }
 private void AddFirefighter(Firefighter firefighter)
 {
     Firefighters.Add(firefighter);
     using (con = new SQLiteConnection(connectionString))
     {
         con.Open();
         try
         {
             using (SQLiteCommand insertSQL = con.CreateCommand())
             {
                 insertSQL.CommandText = "INSERT INTO Strazacy(IdStraz, NazwiskoStraz, ImieStraz, PeselStraz, TelefonStraz, StopienStraz, DataUrodzenia, DataDolaczenia) VALUES (@id,@lastname,@firstname,@pesel,@phone,@degree,@birthdate,@joindate)";
                 insertSQL.Parameters.Add(new SQLiteParameter("@id", SqlDbType.Int)
                 {
                     Value = firefighter.Id
                 });
                 insertSQL.Parameters.AddWithValue("@lastname", firefighter.LastName);
                 insertSQL.Parameters.AddWithValue("@firstname", firefighter.FirstName);
                 insertSQL.Parameters.AddWithValue("@pesel", firefighter.Pesel);
                 insertSQL.Parameters.AddWithValue("@phone", firefighter.Phone);
                 insertSQL.Parameters.AddWithValue("@degree", firefighter.Degree);
                 insertSQL.Parameters.AddWithValue("@birthdate", firefighter.BirthDate);
                 insertSQL.Parameters.AddWithValue("@joindate", firefighter.JoinDate);
                 insertSQL.ExecuteNonQuery();
             }
             con.Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show("Błąd połączenia z bazą: " + ex);
         }
     }
 }
        public FirefighterMenuViewModel(INavigationService navigationService)
        {
            this.navigationService = navigationService;

            AddFirefighterCommand   = new RelayCommand(NewFirefighter);
            EditFirefighterCommand  = new RelayCommand(EditFirefighter);
            RemoveFirefigterCommand = new RelayCommand(RemoveFirefighter);
            CancelCommand           = new RelayCommand(OnExit);


            windowType  = TypeOfWindow.Firefighters;
            windowTitle = Helpers.GetDescription(windowType);

            RegisterMessages();

            using (con)
            {
                try
                {
                    con.Open();
                    LoadFirefighters();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Błąd połączenia z bazą");
                }
                finally
                {
                    con.Close();
                }
            }

            selectedFirefighter = firefighters.ElementAt(0);
        }
Exemple #5
0
        static void Observer()
        {
            var fireman = new Firefighter();

            var house1 = new House(100, 25, 4);
            var house2 = new House(102, 16, 1);
            var house3 = new House(104, 34, 5);
            var house4 = new House(106, 20, 3);
            var house5 = new House(108, 9, 2);
            var square = new Square("San Martin", 36, 5, 4);
            var street = new Street(110, 64, 25);

            house1.Street = street;
            house1.AddObserver(fireman);
            house2.Street = street;
            house2.AddObserver(fireman);
            house3.Street = street;
            house3.AddObserver(fireman);
            house4.Street = street;
            house4.AddObserver(fireman);
            house5.Street = street;
            house5.AddObserver(fireman);
            square.Street = street;
            square.AddObserver(fireman);
            house5.Spark();
            square.Spark();
        }
 public ActionResult Delegate()
 {
     Firefighter joe = new Firefighter() { Name = "Joe"};
     //
     FireChief harry = new FireChief() { Name = "Harry", NumberOne = joe};
     FireChief tom = new FireChief() { Name = "Tom", NumberOne = harry};
     //
     return Content(harry.ExtinguishFire() + "<br>" +
                    tom.ExtinguishFire());
 }
        private static void GenericCollectionPrintTest()
        {
            var cleaner     = new Cleaner("Tom", new DateTime(1994, 11, 20), 600);
            var firefighter = new Firefighter("Jack", new DateTime(1987, 5, 5), 1000);
            var leutenant   = new Leutenant("Igor", new DateTime(1947, 5, 5), 2000);
            var general     = new General("Daniel", new DateTime(1958, 6, 2), 3060);

            Profession[] profesions = { cleaner, firefighter, leutenant, general };
            profesions.Print();
        }
Exemple #8
0
        static void Decorator()
        {
            var fireman = new Firefighter();
            //var square = new Square("San Martin", 9, 5, 4);
            var house  = new House(102, 9, 1, new mixedBuilder());
            var street = new Street(110, 64, 15);

            house.Street = street;
            house.AddObserver(fireman);
            house.Spark();
        }
        public void copyOrDefault(object existingFirefighter)
        {
            var ff = new Firefighter();

            if (null != existingFirefighter)
            {
                var selectedFF = existingFirefighter as Firefighter;
                ff.Car = selectedFF.Car;
                ff.setTimes(selectedFF.DispatchTime, selectedFF.ReturnTime);
            }
            firefighters.Add(ff);
        }
Exemple #10
0
        static void Main(string[] args)
        {
            Random      rnd = new Random();
            Firefighter fr  = new Firefighter(WriteMSG);

            for (int i = 0; i < rnd.Next(); i++)
            {
                Thread.Sleep(100);
                int ev = rnd.Next(102, 104);
                fr.DoEvent("Улица пушкина");
            }
        }
        static void Main(string[] args)
        {
            //Entering a new Firefighter Name, age, and pension
            Firefighter firefighter = new Firefighter("Joe Robinson", 29);

            firefighter.PensionAmmount = 4500;

            Console.WriteLine(firefighter.Name + " is your newest firefighter.");
            Console.WriteLine("Age: " + firefighter.Age);
            Console.WriteLine("Pension: $" + firefighter.PensionAmmount);

            //Puts out the fire (hopefully)
            putOutFire();

            Console.ReadKey();
        }
Exemple #12
0
        public static void Main(string[] args)
        {
            Firefighter firefighter = new Firefighter("Joe Carrington", 35);

            firefighter.PensionAmount = 5000;
            PrintNameAndAge(firefighter);
            PrintPensionAmount(firefighter);

            firefighter.DriveToPlaceOfInterest();
            PoliceOfficer officer = new PoliceOfficer("Jane Hope", 32);

            officer.PensionAmount = 5500;
            officer.HasEmergency  = true;

            PrintNameAndAge(officer);
            PrintPensionAmount(officer);
            officer.DriveToPlaceOfInterest();
        }
        private void ChangeFirefighter(Firefighter firefighter)
        {
            for (int i = 0; i < Firefighters.Count; i++)
            {
                if (Firefighters[i].Id == firefighter.Id)
                {
                    Firefighters[i] = firefighter.Clone();
                }
            }
            CollectionViewSource.GetDefaultView(this.Firefighters).Refresh();


            using (con = new SQLiteConnection(connectionString))
            {
                try
                {
                    con.Open();
                    using (SQLiteCommand command = new SQLiteCommand(con))
                    {
                        command.CommandText =
                            "UPDATE Strazacy SET NazwiskoStraz = @lastName, ImieStraz = @firstName, PeselStraz = @pesel," +
                            "TelefonStraz = @phone, StopienStraz = @degree, DataUrodzenia = @birthdate, DataDolaczenia = @joindate " +
                            "WHERE IdStraz=@id";
                        command.Parameters.AddWithValue("id", firefighter.Id);
                        command.Parameters.AddWithValue("lastName", firefighter.LastName);
                        command.Parameters.AddWithValue("firstName", firefighter.FirstName);
                        command.Parameters.AddWithValue("pesel", firefighter.Pesel);
                        command.Parameters.AddWithValue("phone", firefighter.Phone);
                        command.Parameters.AddWithValue("degree", firefighter.Degree);
                        command.Parameters.AddWithValue("birthdate", firefighter.BirthDate);
                        command.Parameters.AddWithValue("joindate", firefighter.JoinDate);
                        command.ExecuteNonQuery();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Błąd połączenia z bazą: " + ex);
                }
                finally
                {
                    con.Close();
                }
            }
        }
        //
        // GET: /Chapter4/
        public ActionResult Index()
        {
            Firetruck truckOne = new Firetruck();
            //隊員
            Firefighter joe = new Firefighter() { Name = "Joe" };
            Firefighter frank = new Firefighter() { Name = "Frank" };
            //隊長,繼承Firefighter
            FireChief bigChiefHarry = new FireChief() { Name = "Harry"};
            //
            truckOne.Driver = bigChiefHarry;
            bigChiefHarry.Drive(truckOne, new Point(100, 300));
            bigChiefHarry.TellFirefighterToExtinguishFire(joe);
            //return Content(bigChiefHarry.ExtinguishFire());
            //
            //取代Base Class裡的ExtinguishFire方法
            FireChief harry = new FireChief() { Name = "Harry", NumberOne = joe };

            return Content(harry.ExtinguishFire());
        }
 public ActionResult RollCall()
 {
     FireStation station = new FireStation();
     Firefighter joe = new Firefighter() { Name = "Joe" };
     FirefighterBase bill = new TraineeFirefighter() { Name = "Bill" };
     FireChief bigChiefHarry = new FireChief() { Name = "Harry" };
     Administrator arthur = new Administrator()
     {
         Title = "Mr",
         Forename = "Arthur",
         Surname = "Askey"
     };
     station.ClockIn(joe);
     station.ClockIn(bill);
     station.ClockIn(bigChiefHarry);
     station.ClockIn(arthur);
     //
     return Content(station.RollCall());
 }
Exemple #16
0
        private void CreateFiretrucks()
        {
            cones        = new List <Rage.Object>();
            firetrucks   = new List <Vehicle>();
            firefighters = new List <Firefighter>();
            if (locationData.FiretrucksSpawns != null)
            {
                foreach (BrushFireLocationData.FiretruckSpawnData sp in locationData.FiretrucksSpawns)
                {
                    Vector3 p = sp.Position;
                    float?  z = World.GetGroundZ(p, false, true);
                    if (z.HasValue)
                    {
                        p.Z = z.Value;
                    }
                    Vehicle v = new Vehicle("firetruk", p, sp.Heading);
                    v.IsSirenOn = true;
                    if (sp.SideCones || sp.FrontCones || sp.RearCones)
                    {
                        switch (sp.ConesPosition)
                        {
                        case BrushFireLocationData.FiretruckSpawnData.ConesPositionType.Left: cones.AddRange(Functions.CreateConesAtVehicleLeftSide(v, 3.25f, true, sp.SideCones, sp.FrontCones, sp.RearCones)); break;

                        case BrushFireLocationData.FiretruckSpawnData.ConesPositionType.Right: cones.AddRange(Functions.CreateConesAtVehicleRightSide(v, 3.25f, true, sp.SideCones, sp.FrontCones, sp.RearCones)); break;
                        }
                    }
                    firetrucks.Add(v);

                    int seats = Math.Min(4, v.PassengerCapacity + 1);
                    for (int i = 0; i < seats; i++)
                    {
                        Firefighter f = new Firefighter(Vector3.Zero, 0.0f);
                        f.PreferedVehicleSeatIndex      = i - 1;
                        f.Equipment.HasFireExtinguisher = true;
                        f.Equipment.HasFireGear         = true;
                        f.Equipment.IsFlashlightOn      = true;
                        f.Ped.WarpIntoVehicle(v, i - 1);
                        f.Ped.Metadata.Firetruck = v;
                        firefighters.Add(f);
                    }
                }
            }
        }
Exemple #17
0
    void Update()
    {
        if (FirefighterManager.instance.firefighters.Count == 0)
        {
            if (Input.GetMouseButtonDown(0))
            {
                Debug.Log("mouse clicked");
                Vector3 cameraPos            = Camera.main.transform.position;
                Vector3 mousePos             = Input.mousePosition + new Vector3(0, 0, -cameraPos.z);
                Vector3 mousePosInWorldPoint = Camera.main.ScreenToWorldPoint(mousePos);
                Tile    tile = grid.WorldPointToTile(mousePosInWorldPoint);

                if (tile.isOutside)
                {
                    FirefighterManager.instance.AddFirefighter(tile.worldPosition);
                }
            }
        }
        else
        {
            if (Input.GetMouseButtonDown(0))
            {
                Debug.Log("mouse clicked");
                Vector3 cameraPos            = Camera.main.transform.position;
                Vector3 mousePos             = Input.mousePosition + new Vector3(0, 0, -cameraPos.z);
                Vector3 mousePosInWorldPoint = Camera.main.ScreenToWorldPoint(mousePos);
                Tile    targetTile           = grid.WorldPointToTile(mousePosInWorldPoint);

                firefighter = FirefighterManager.instance.firefighters[0];
                Vector3 firefighterPos = firefighter.transform.position;
                Tile    currentTile    = grid.WorldPointToTile(firefighterPos);

                int dist = pathfinder.GetDistance(currentTile, targetTile);
                if (firefighter.actionPoints != 0 && firefighter.actionPoints >= dist)
                {
                    firefighter.transform.position = targetTile.worldPosition;
                    firefighter.actionPoints      -= dist;
                    Debug.Log("remaining AP: " + firefighter.actionPoints);
                }
            }
        }
    }
Exemple #18
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);
        }
Exemple #19
0
 public FirefighterSecretary(Firefighter firefighter)
 {
     Firefighter = firefighter;
 }
 public string TellFirefighterToExtinguishFire(Firefighter colleafue)
 {
     return colleafue.ExtinguishFire();
 }
 public ActionResult Override()
 {
     Firefighter joe = new Firefighter() { Name = "Joe"};
     FirefighterBase bill = new TraineeFirefighter() { Name = "Bill"};
     return Content(joe.ExtinguishFire() + "<br>" + bill.ExtinguishFire());
 }
Exemple #22
0
        static void Iterator()
        {
            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();

            // BOARD
            var complaintsByBoard = new ComplaintByBoard();

            A.AddObserver(complaintsByBoard);
            B.AddObserver(complaintsByBoard);
            C.AddObserver(complaintsByBoard);
            D.AddObserver(complaintsByBoard);
            E.AddObserver(complaintsByBoard);
            F.AddObserver(complaintsByBoard);

            // 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);
            var complaintsByWhatsapp = new ComplaintByWhatsapp(whatsAppList);

            // DESK
            var complaintsByDesk = new ComplaintByDesk(J);

            B.Spark();
            F.Spark();

            // TEST
            var fireman = new Firefighter();

            fireman.Vehicle = new FireTruck();
            fireman.Tool    = new WaterHose();
            var secretary = new FirefighterSecretary(fireman);

            secretary.AttendCompliant(complaintsByBoard);
            secretary.AttendCompliant(complaintsByDesk);
            Console.Clear();
            secretary.AttendCompliant(complaintsByWhatsapp);
        }