Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ferry"></param>
        /// <returns></returns>
        public static Ferry UpdateFerry(Ferry ferry)
        {
            DBUtility.HandleConnection((MySqlCommand command) =>
            {
                command.CommandText = "UPDATE ferries SET " +
                                      "name = @name, " +
                                      "size = @size, " +
                                      "passenger_capacity = @passenger_capacity, " +
                                      "vehicle_capacity = @vehicle_capacity, " +
                                      "municipality = @municipality, " +
                                      "dock_id = @dock_id " +
                                      "WHERE id = @id;";

                command.Parameters.AddWithValue("@name", ferry.FerryName);
                command.Parameters.AddWithValue("@size", ferry.FerrySize);
                command.Parameters.AddWithValue("@passenger_capacity", ferry.PassengerCapacity);
                command.Parameters.AddWithValue("@vehicle_capacity", ferry.VehicleCapacity);
                command.Parameters.AddWithValue("@municipality", ferry.Municipality);
                command.Parameters.AddWithValue("@dock_id", ferry.Dock.DockId);
                command.Parameters.AddWithValue("@id", ferry.FerryId);

                int rowsAffected = command.ExecuteNonQuery();

                //If the update fails, dock is set to null
                if (rowsAffected != 1)
                {
                    ferry = null;
                }
            });

            return(ferry);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ferryId"></param>
        /// <returns></returns>
        public static Ferry GetFerry(int ferryId)
        {
            Ferry ferry = null;

            DBUtility.HandleConnection((MySqlCommand command) =>
            {
                command.CommandText = "SELECT * FROM ferries WHERE id = @id;";

                command.Parameters.AddWithValue("@id", ferryId);

                using (MySqlDataReader reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        ferry = new Ferry()
                        {
                            FerryId           = reader.GetInt32("id"),
                            FerryName         = reader.GetString("name"),
                            FerrySize         = reader.GetString("size"),
                            PassengerCapacity = reader.GetInt32("passenger_capacity"),
                            VehicleCapacity   = reader.GetInt32("vehicle_capacity"),
                            Municipality      = reader.GetString("municipality"),
                            Dock = DockHandler.GetDock(reader.GetInt32("dock_id"))
                        };
                    }
                }
            });

            return(ferry);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            int ferryID = 0;
            if (Request.QueryString["FerryID"] != null)
            {
                ferryID = Convert.ToInt32(Request.QueryString["FerryID"]);
                Session["Prop_Action"] = "U";
            }
            if (Session["Prop_Action"] == "U")
            {
                // int proID= int.Parse(Session["Pro_ID"].ToString());
                Ferry ferry = new Ferry();
                ferry.Ferry_ID = ferryID;
                ferry.SelectOne();

                hidFerryID.Value      = ferry.Ferry_ID.ToString();
                txtFerryNameEn.Text   = ferry.FerryName_EN.ToString();
                txtFerryNameAr.Text   = ferry.FerryName_AR.ToString();
                txtCostForAdults.Text = ferry.Cost_For_Adults.ToString();
                txtCostForKids.Text   = ferry.Cost_For_Kids.ToString();
            }
        }
    }
Пример #4
0
        public override void Puzzle2()
        {
            Ferry ferry = new Ferry(input, 0, 0, Directions.E, 10, 1);

            ferry.MoveFerryWithWaypoint();
            Console.WriteLine($"The manhattan distance is {ferry.calcManhattanDistance()}");
        }
Пример #5
0
        public Position Execute(IEnumerable <string> directions)
        {
            var ferry  = new Ferry();
            var result = ferry.Sail(directions);

            return(result);
        }
Пример #6
0
        public void correctToStringPrints()
        {
            string expectedOut = "Vessel: Vessel name: PerryTheFerry, Year built: 2001, Amount of passengers: 2000";
            var    ferry       = new Ferry("PerryTheFerry", "2001", "30", 2000);

            Assert.Equal(expectedOut, ferry.ToString());
        }
Пример #7
0
        public static void Main()
        {
            // Build a collection of all vehicles that fly
            var cessna = new Cessna();
            var archer = new PiperArcher();

            var airVehicles = new List <IAircraft> {
                cessna, archer
            };

            // With a single `foreach`, have each vehicle Fly()

            foreach (var aircraft in airVehicles)
            {
                aircraft.Start();
                aircraft.Fly();
                aircraft.Stop();
                Console.ReadLine();
            }



            // Build a collection of all vehicles that operate on roads
            var motorcycle = new Motorcycle();
            var ambulance  = new Ambulance();

            var landVehicles = new List <ILandCraft> {
                motorcycle, ambulance
            };

            // With a single `foreach`, have each road vehicle Drive()

            foreach (var vehicle in landVehicles)
            {
                vehicle.Start();
                vehicle.Drive();
                vehicle.Stop();
                Console.ReadLine();
            }



            // Build a collection of all vehicles that operate on water
            var jetSki = new JetSki();
            var ferry  = new Ferry();

            var waterVehicles = new List <IWaterCraft> {
                ferry, jetSki
            };

            // With a single `foreach`, have each water vehicle Drive()

            foreach (var waterCraft in waterVehicles)
            {
                waterCraft.Start();
                waterCraft.Drive();
                waterCraft.Stop();
                Console.ReadLine();
            }
        }
    private bool SaveReservationPayment(SqlInt32 reservationId, Ferry ferry, int ferryAdultOrChild)
    {
        Reservation_Payments pay = new Reservation_Payments();

        pay.Reservation_ID      = reservationId;
        pay.PaymentPersonnel    = 0;//Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name);
        pay.CreatedDate         = Utility.GetSqlDateTimeFromDateTime(DateTime.Today);
        pay.Discount_ID         = SqlInt32.Parse(this.hidDiscountId.Value);
        pay.AvailedService_Type = ferryAdultOrChild; //1=Reservation;2=Bills & Services;3=Amenities
        pay.Discount_Offered    = new SqlMoney(0.00);
        pay.Rate_ID             = (SqlInt32)ferry.Ferry_ID;
        pay.PaymentStatus       = PaymentStatus.NOT_PAID;

        /*
         * if (ferryAdultOrChild == PAYMENT_AVAILED_SERVICETYPES.FERRY_ADULTS)
         * {
         *  pay.UnitsConsumed = SqlInt32.Parse(this.drpNumberOfAdults.SelectedValue);
         *  pay.TotalCost_Before_Discount = (ferry.Cost_For_Adults * pay.UnitsConsumed);
         *  SqlMoney costAfterDiscount = (pay.TotalCost_Before_Discount - pay.Discount_Offered);
         *  pay.Cost_After_Discount = costAfterDiscount;
         * }
         * else if (ferryAdultOrChild == PAYMENT_AVAILED_SERVICETYPES.FERRY_KIDS)
         * {
         *  pay.UnitsConsumed = SqlInt32.Parse(this.drpNumberOfChildren.SelectedValue);
         *  pay.TotalCost_Before_Discount = (ferry.Cost_For_Kids * pay.UnitsConsumed);
         *  SqlMoney costAfterDiscount = (pay.TotalCost_Before_Discount - pay.Discount_Offered);
         *  pay.Cost_After_Discount = costAfterDiscount;
         * }
         */
        pay.AmountReceived = 0;
        return(pay.Insert());
    }
Пример #9
0
        public void Puzzle2_FollowInstructionsWithWaypoint_AndFindManhattanDistance()
        {
            var ferry = new Ferry(Input.Day12);

            ferry.FollowInstructionsWithWaypoint();

            ferry.ManhattanDistance.Should().Be(35292);
        }
Пример #10
0
        public void Puzzle1_FollowInstructions_AndFindManhattanDistance()
        {
            var ferry = new Ferry(Input.Day12);

            ferry.FollowInstructions();

            ferry.ManhattanDistance.Should().Be(1645);
        }
Пример #11
0
        public void TestMethod2()
        {
            Vessel ship = new Ferry("Fer", "2001", 25.5, "4");

            var result = ship.GetVesselInfo();

            Assert.AreEqual("Ferry Fer 2001 4", result);
        }
Пример #12
0
 public static void Stop()
 {
     Trans?.Stop();
     TileLifter?.Stop();
     Ferry?.Stop();
     Carrier?.Stop();
     Rf?.Stop();
 }
Пример #13
0
        public void FerryAndWaypoint_FollowInstructions_WithExample_EndsUpInCorrectPlace()
        {
            var ferry = new Ferry(Example);

            ferry.FollowInstructionsWithWaypoint();

            (ferry.X, ferry.Y).Should().Be((214, -72));
            ferry.ManhattanDistance.Should().Be(286);
        }
Пример #14
0
        public void Ferry_FollowInstructions_WithExample_EndsUpInCorrectPlace()
        {
            var ferry = new Ferry(Example);

            ferry.FollowInstructions();

            (ferry.X, ferry.Y).Should().Be((17, -8));
            ferry.ManhattanDistance.Should().Be(25);
        }
Пример #15
0
        public void FerryPassengersTest()
        {
            Ferry testPassangers = new Ferry("Test ferry", "2017", "Ferry", new Speed(56), passengers: 134);

            int expectedNumber = 134;

            int actualNumber = testPassangers.Passengers;

            Assert.Equal(expectedNumber, actualNumber);
        }
Пример #16
0
        private static string SolvePart2(List <string> input)
        {
            var actions = input.Select(x => Action.Parse(x)).ToList();

            var ferry = new Ferry();

            actions.ForEach(action => ferry.ExecuteActionPartTwo(action));

            return(ferry.CalculateManhattanDistance().ToString());
        }
Пример #17
0
        public int SolvePart2()
        {
            ferry = new Ferry(true);

            foreach (var ins in ParseData())
            {
                ferry.Move(ins);
            }

            return(ferry.GetTravelDistance());
        }
        public void FerryCanSail(string expectedPos, int expectedManhattanDistance, params string[] directions)
        {
            // Arrange
            var sut = new Ferry();

            // Act
            var result = sut.Sail(directions);

            // Assert
            result.ToString().Should().Be(expectedPos);
            result.ManhattanDistance.Should().Be(expectedManhattanDistance);
        }
Пример #19
0
        public void Example_ImportsInstructionsCorrectly()
        {
            var ferry = new Ferry(Example);

            Assert.Collection(ferry.Instructions,
                              item => { item.Direction.Should().Be(Direction.F); item.Value.Should().Be(10); },
                              item => { item.Direction.Should().Be(Direction.N); item.Value.Should().Be(3); },
                              item => { item.Direction.Should().Be(Direction.F); item.Value.Should().Be(7); },
                              item => { item.Direction.Should().Be(Direction.R); item.Value.Should().Be(90); },
                              item => { item.Direction.Should().Be(Direction.F); item.Value.Should().Be(11); })
            ;
        }
Пример #20
0
 private static void CheckAndStart()
 {
     while (!PubMaster.IsReady)
     {
         Thread.Sleep(2000);
     }
     TileLifter?.Start();
     Ferry?.Start();
     Carrier?.Start();
     Trans?.Start();
     Rf?.Start();
 }
Пример #21
0
    private void BindFerry()
    {
        DataTable table = new Ferry().SelectAll();

        if (table.Rows.Count > 0)
        {
            drpFerry.DataSource     = table;
            drpFerry.DataTextField  = table.Columns["FerryName_EN"].ToString();
            drpFerry.DataValueField = table.Columns["Ferry_ID"].ToString();
            drpFerry.DataBind();
        }
    }
 private void GetFerry(ref DataTable ferryTbl)
 {
     if (Session["FerryTable"] == null)
     {
         Ferry ferry = new Ferry();
         ferryTbl = ferry.SelectAll();
         Session.Add("FerryTable", ferryTbl);
     }
     else
     {
         ferryTbl = (DataTable)Session["FerryTable"];
     }
 }
Пример #23
0
        public override MapItem Deserialize(BinaryReader r)
        {
            var ferry = new Ferry(false);

            ReadKdopItem(r, ferry);

            ferry.Port         = r.ReadToken();
            ferry.PrefabLink   = new UnresolvedItem(r.ReadUInt64());
            ferry.Node         = new UnresolvedNode(r.ReadUInt64());
            ferry.UnloadOffset = r.ReadVector3();

            return(ferry);
        }
        public void FerryGoesToAllPorts()
        {
            var ferry = new Ferry();

            ferry.GoTo(Destination.BusDepot);
            ferry.GoTo(Destination.CityCentre);
            ferry.GoTo(Destination.EasternSuburbs);
            ferry.GoTo(Destination.MainWharf);
            ferry.GoTo(Destination.Northside);
            ferry.GoTo(Destination.PortLevy);
            ferry.GoTo(Destination.QuailIsland);
            ferry.GoTo(Destination.TrainStation);
            Assert.AreEqual(3, ferry.PortsVisitedCount);
        }
Пример #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ferry"></param>
        /// <returns></returns>
        public static bool DeleteFerry(Ferry ferry)
        {
            bool result = false;

            DBUtility.HandleConnection((MySqlCommand command) =>
            {
                command.CommandText = "DELETE FROM ferries WHERE id = @id;";

                command.Parameters.AddWithValue("@id", ferry.FerryId);

                result = command.ExecuteNonQuery() == 1;
            });

            return(result);
        }
Пример #26
0
    static void Main(string [] args)
    {
        Ferry ferry = new Ferry();
        bool carsLeft;  // this flag controls the while loop
        string decision;  // used to test whether there are more cars to board the ferry

        Console.WriteLine("Welcome to Dublin / Hollyhead Ferry\n");

        // do while loop ensures a least one car per day will be boarded
        //
        do
        {
            // get the registration of the car
            Console.Write("Enter the car registration: ");
            ferry.setRegistration(Console.ReadLine());

            // get the number of people in the car
            Console.Write("How many people are in the car " + ferry.getRegNumber() + ": ");
            ferry.setNoPassengers(int.Parse(Console.ReadLine()));
            ferry.getAdultPassengers();

            // calculate the charge of boarding the ferry
            ferry.calcCharge();
            Console.WriteLine("The Charge for " + ferry.getRegNumber() + " is \u00A3" + ferry.getCharge());

            // ask user if there are more cars to board the ferry
            Console.Write("\nAre there any more cars waiting to board (yes/no)? ");
            decision = Console.ReadLine();
            if (decision == "yes")
            {
                carsLeft = true;
            }
            else
            {
                carsLeft = false;
            }
            Console.WriteLine();
        }
        while (carsLeft);

        // display the stats for the day
        Console.WriteLine("The total number of passengers today were " + ferry.getTotalPassengers());
        Console.WriteLine("The total number of cars today were " + ferry.getTotalCars());
        Console.WriteLine("The total charges for the day were " + ferry.getTotalCharge());
        Console.WriteLine("The number of cars with one passenger were " + ferry.getSinglePassengers());
        Console.Write("Press Any Key to continue . . . . .");
        string tmp = Console.ReadLine();
    }
Пример #27
0
    private void DeleteFerry(int ferryId)
    {
        Ferry ferry = new Ferry();

        ferry.Ferry_ID = ferryId;
        ferry.SelectOne();
        if (ferry.Delete())
        {
            BindGridView(0);
        }
        else
        {
            lblMsg.Text      = DBResult.FAILURE + " Could not Delete.";
            lblMsg.ForeColor = Color.Red;
        }
    }
Пример #28
0
        public static int Problem1()
        {
            List <string> data = File.ReadAllLines("Data/Day11.txt").ToList();

            Ferry ferry = new Ferry();

            ferry.Setup(data);

            int loops = ferry.RunUntilStable();

            int result = ferry.Occupied;

            Console.WriteLine(result);

            return(result);
        }
        public static void OnWorldLoadFinished(object sender, EventArgs e)
        {
            if (alreadyParsed)
            {
                Ferry <PersistedData> .UnloadCargo();
            }
            alreadyParsed = false;
            ObjectLoader.FindAndSortAllExistingSewables();

            for (int i = 0; i < Sims3.Gameplay.Queries.GetObjects <PhoneSmart>().Length; i++)
            {
                if (Sims3.Gameplay.Queries.GetObjects <PhoneSmart>()[i] != null)
                {
                    AddInteractionsPhone(Sims3.Gameplay.Queries.GetObjects <PhoneSmart>()[i]);
                }
            }

            foreach (Computer computer in Sims3.Gameplay.Queries.GetObjects <Computer>())
            {
                if (computer != null)
                {
                    AddInteractionsComputer(computer);
                }
            }

            // Save/cache our loaded key to make discovery quicker. Rather than always looping through it.
            for (int i = 0; i < ObjectLoader.sewableSettings.Count; i++)
            {
                Pattern.mStoredPatternsKeySettingsList.Add(ObjectLoader.sewableSettings[i].key);
            }

            foreach (KeyValuePair <ulong, bool> keyvalues in GlobalOptionsSewingTable.retrieveData.whoIsInPatternClub)
            {
                print("Re-assigned the mailbox alarm!");
                SimDescription description = SimDescription.Find(keyvalues.Key);
                Mailbox        mailbox     = Mailbox.GetMailboxOnLot(description.LotHome);
                mailbox.AddAlarmDay(1f, DaysOfTheWeek.Thursday, GlobalOptionsSewingTable.SendPatterns, "Mailbox:  Pattern club " + description.mSimDescriptionId.ToString(), AlarmType.AlwaysPersisted);
            }
            //mPatternClubAlarm = AlarmManager.Global.AddAlarmDay(1f, DaysOfTheWeek.Thursday, GlobalOptionsSewingTable.SendPatterns, "Mailbox:  Pattern club", AlarmType.NeverPersisted, null);

            //mWearClothing = AlarmManager.Global.AddAlarmRepeating(24f, TimeUnit.Hours, WearGiftedClothing, 1f, TimeUnit.Days, "Wear gifted clothing", AlarmType.AlwaysPersisted, null);

            EventTracker.AddListener(EventTypeId.kBoughtObject, new ProcessEventDelegate(OnObjectChanged));
            EventTracker.AddListener(EventTypeId.kInventoryObjectAdded, new ProcessEventDelegate(OnObjectChanged));
            EventTracker.AddListener(EventTypeId.kObjectStateChanged, new ProcessEventDelegate(OnObjectChanged));
        }
        public static void OnWorldQuit(object sender, EventArgs e)
        {
            Ferry <PersistedData> .LoadCargo();

            foreach (KeyValuePair <ulong, bool> keyvalues in GlobalOptionsSewingTable.retrieveData.whoIsInPatternClub)
            {
                print("Re-assigned the mailbox alarm!");
                SimDescription description = SimDescription.Find(keyvalues.Key);
                Mailbox        mailbox     = Mailbox.GetMailboxOnLot(description.LotHome);
                mailbox.RemoveAlarm(1f, DaysOfTheWeek.Thursday, GlobalOptionsSewingTable.SendPatterns, "Mailbox:  Pattern club " + description.mSimDescriptionId.ToString(), AlarmType.AlwaysPersisted);
            }
            //AlarmManager.Global.RemoveAlarm(mPatternClubAlarm);
            //mPatternClubAlarm = AlarmHandle.kInvalidHandle;

            //AlarmManager.Global.RemoveAlarm(mWearClothing);
            //mWearClothing = AlarmHandle.kInvalidHandle;
        }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            Ferry ferry = new Ferry();
            ferry.FerryName_EN     = txtFerryNameEn.Text;
            ferry.FerryName_AR     = txtFerryNameAr.Text;
            ferry.Cost_For_Adults  = SqlMoney.Parse(txtCostForAdults.Text.Trim());
            ferry.Cost_For_Kids    = SqlMoney.Parse(txtCostForKids.Text.Trim());
            ferry.LastModifiedUser = Utility.GetUserIdFromUserName(HttpContext.Current.User.Identity.Name);
            ferry.LastModifiedDate = Utility.GetSqlDateTimeFromDateTime(DateTime.Now);
            if (Session["Prop_Action"] == "U")
            {
                ferry.Ferry_ID = int.Parse(hidFerryID.Value);
                if (ferry.Update())
                {
                    DisplayDBResult(DBResult.SUCCESS, "Successfully Updated");
                }
                else
                {
                    DisplayDBResult(DBResult.FAILURE, "Failed to Update");
                }

                Session.Remove("Prop_Action");
            }
            else
            {
                ferry.CreatedUser = ferry.LastModifiedUser;
                ferry.CreatedDate = ferry.LastModifiedDate;
                if (ferry.Insert())
                {
                    DisplayDBResult(DBResult.SUCCESS, "Successfully Inserted");
                }
                else
                {
                    DisplayDBResult(DBResult.FAILURE, "Failed to Insert");
                }
            }
            lblMsg.Text      = "Data Saved successfully.";
            lblMsg.ForeColor = Color.Green;
        }
        catch (Exception ex)
        {
            DisplayDBResult(DBResult.EXCEPTION, ex.Message);
        }
    }