public RowBoatRope(RowBoat rowBoat, int northItemID, Point3D initOffset)
     : base(rowBoat, northItemID, initOffset)
 {
     _rowBoat = rowBoat;
     Movable  = false;
     Name     = "Mooring Line";
 }
示例#2
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 1:
            {
                Boat          = reader.ReadItem() as RowBoat;
                _multiIDNorth = reader.ReadInt();
                _multiIDEast  = reader.ReadInt();
                _multiIDSouth = reader.ReadInt();
                _multiIDWest  = reader.ReadInt();

                goto case 0;
            }

            case 0:
            {
                MultiID = reader.ReadInt();
                Offset  = reader.ReadPoint3D();

                break;
            }
            }

            if (Weight == 0.0)
            {
                Weight = 1.0;
            }
        }
示例#3
0
        public static void Main()
        {
            //------------------------------------------------------------------------
            // Build a collection of all vehicles that fly
            // With a single `foreach`, have each vehicle Fly()
            PassengerPlane plane1 = new PassengerPlane();
            PrivateJet     plane2 = new PrivateJet();
            Spaceship      plane3 = new Spaceship();
            //creat a list of planes
            var planes = new List <Aircraft>();

            planes.Add(plane1);
            planes.Add(plane2);
            planes.Add(plane3);
            //loop over the list with a foreach and call method Fly() for each one
            foreach (var plane in planes)
            {
                plane.Fly();
            }
            //--------------------------------------------------------------------------


            //------------------------------------------------------------------------
            // Build a collection of all vehicles that operate on roads
            // With a single `foreach`, have each road vehicle Drive()
            NissanLeaf  car1 = new NissanLeaf();
            NissanKicks car2 = new NissanKicks();
            NissanRogue car3 = new NissanRogue();
            //creat a list of cars
            var cars = new List <Car>();

            cars.Add(car1);
            cars.Add(car2);
            cars.Add(car3);
            //loop over the list with a foreach and call method Drive() for each one
            foreach (var car in cars)
            {
                car.Drive();
            }
            //--------------------------------------------------------------------------

            //--------------------------------------------------------------------------
            // Build a collection of all vehicles that operate on water
            // With a single `foreach`, have each water vehicle Drive()
            MotorBoat boat1 = new MotorBoat();
            RowBoat   boat2 = new RowBoat();
            Yacht     boat3 = new Yacht();
            //creat a list of boat
            var boats = new List <Watercraft>();

            boats.Add(boat1);
            boats.Add(boat2);
            boats.Add(boat3);
            //loop over the list with a foreach and call method Drive() for each one
            foreach (var boat in boats)
            {
                boat.Drive();
            }
            //--------------------------------------------------------------------------
        }
示例#4
0
        public void StartRace_Race_ShouldOrderWinnersByTime()
        {
            var first  = new RowBoat("rowboat1", 80, 4);
            var second = new RowBoat("rowboat2", 90, 4);
            var third  = new RowBoat("rowboat3", 100, 4);

            this.controller.OpenRace(5000, 10, 5, false);
            this.controller.CurrentRace.AddParticipant(first);
            this.controller.CurrentRace.AddParticipant(second);
            this.controller.CurrentRace.AddParticipant(third);

            var distance   = this.controller.CurrentRace.Distance;
            var firstTime  = distance / first.CalculateRaceSpeed(this.controller.CurrentRace);
            var secondTime = distance / second.CalculateRaceSpeed(this.controller.CurrentRace);
            var thirdTime  = distance / third.CalculateRaceSpeed(this.controller.CurrentRace);

            var expected = new StringBuilder();

            expected.AppendLine(string.Format(
                                    "First place: RowBoat Model: rowboat1 Time: {0} sec",
                                    firstTime.ToString("0.00")));
            expected.AppendLine(string.Format(
                                    "Second place: RowBoat Model: rowboat2 Time: {0} sec",
                                    secondTime.ToString("0.00")));
            expected.Append(string.Format(
                                "Third place: RowBoat Model: rowboat3 Time: {0} sec",
                                thirdTime.ToString("0.00")));

            var actual = this.controller.StartRace();

            Assert.AreEqual(expected.ToString(), actual);
        }
示例#5
0
        static void ThingsARowBoatCanDo()
        {
            RowBoat rowboat = new RowBoat();

            Console.WriteLine("-----Does a rowBoat have a Bow?-----");
            bool output1 = rowboat.HasBow;

            Console.WriteLine(output1);
            Console.WriteLine("-----is a rowBoat Real?-----");
            bool output2 = rowboat.IsReal;

            Console.WriteLine(output2);
            Console.WriteLine("is a row boat cool?");
            bool output3 = rowboat.IsCool;

            Console.WriteLine(output3);
            Console.WriteLine("-----can a rowBoat drive?-----");
            Console.WriteLine(rowboat.Drives());
            Console.WriteLine("-----Can the rowBoat turn on?-----");
            Console.WriteLine(rowboat.TurnOn());
            Console.WriteLine("-----Can the rowBoat turn off?-----");
            Console.WriteLine(rowboat.TurnOff());
            Console.WriteLine("price:");
            Console.WriteLine(rowboat.Price);
        }
        public string CreateRowBoat(string model, int weight, int oars)
        {
            IBoat boat = new RowBoat(model, weight, oars);

            this.Database.Boats.Add(boat);
            return(string.Format("Row boat with model {0} registered successfully.", model));
        }
示例#7
0
        void NewBoats()
        {
            int boatType;

            for (int count = 0; count < 5; count++)
            {
                boatType = Rand.Next(0, 0 + 1);

                switch (boatType)
                {
                case 0:
                    TheArrivingBoats[count] = new RowBoat();
                    break;

                default:
                    break;
                }
            }

            for (int index = 0; index < TheArrivingBoats.Length; index++)
            {
                int sizeNewBoat = TheArrivingBoats[index].GetSize();

                //TheHorizontalBoatList.

                for (int jindex = 1; jindex < TheHorizontalBoatList.Count - 1; jindex++)
                {
                }
            }
        }
示例#8
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            reader.ReadInt();
            _baseItemID   = reader.ReadInt();
            LinkedRowBoat = reader.ReadItem() as RowBoat;
        }
        public string CreateRowBoat(string model, int weight, int oars)
        {
            IBoat boat = new RowBoat(model, weight, oars);

            this.Database.Boats.Add(boat);

            return(string.Format(Constants.SuccessfullCreateBoat, "Row boat", model));
        }
示例#10
0
        public void OnPlacement(Mobile from, Point3D p)
        {
            if (Deleted)
            {
                return;
            }
            else if (!IsChildOf(from.Backpack))
            {
                from.SendLocalizedMessage(1042001);                   // That must be in your pack for you to use it.
            }
            else
            {
                Map map = from.Map;

                if (map == null)
                {
                    return;
                }

                if (from.AccessLevel < AccessLevel.GameMaster && (map == Map.Ilshenar || map == Map.Malas))
                {
                    from.SendLocalizedMessage(1043284);                       // A ship can not be created here.
                    return;
                }

                if (from.Region.IsPartOf(typeof(HouseRegion)) /*|| BaseGalleon.FindBoatAt( from, from.Map ) != null */)
                {
                    from.SendLocalizedMessage(1010568, null, 0x25);                       // You may not place a ship while on another ship or inside a house.
                    return;
                }

                RowBoat boat = new RowBoat();

                p = new Point3D(p.X - Offset.X, p.Y - Offset.Y, p.Z - Offset.Z);

                if (/*BaseSmoothMulti.IsValidLocation( p, map ) &&*/ boat.CanFit(p, map, boat.ItemID))
                {
                    if (Boat != null)
                    {
                        Boat.Delete();
                    }

                    boat.Owner = from;

                    boat.MoveToWorld(p, map);

                    boat.SetFacing(m_ChosenDirection);

                    Boat = boat;
                }
                else
                {
                    boat.Delete();
                    from.SendLocalizedMessage(1043284);                       // A ship can not be created here.
                }
            }
        }
        public void RowBoatCanTurnOn()
        {
            //arrange
            RowBoat rowboat = new RowBoat();

            //act
            string var = rowboat.TurnOn();

            Assert.Equal("The boat cannot turn on", var);
        }
        public void RowBoatHasBow()
        {
            //arrange
            RowBoat rowboat = new RowBoat();
            //act
            bool output1 = rowboat.HasBow;

            //assert
            Assert.True(output1);
        }
        public void RowBoatCanTurnOff()
        {
            //arrange
            RowBoat rowboat = new RowBoat();
            //act
            string var = rowboat.TurnOff();

            //assert
            Assert.Equal("The boat has turned off.", var);
        }
        public void RowBoatCanDrive()
        {
            //arrange
            RowBoat rowboat = new RowBoat();
            //act
            string var = rowboat.Drives();

            //assert
            Assert.Equal("The Boat is going somewhere. and is cool : True", var);
        }
示例#15
0
        public void StartRace_InsufficientContestants_ShouldThrow()
        {
            var first  = new RowBoat("rowboat1", 100, 4);
            var second = new RowBoat("rowboat2", 90, 4);

            this.controller.OpenRace(5000, 10, 5, false);
            this.controller.CurrentRace.AddParticipant(first);
            this.controller.CurrentRace.AddParticipant(second);

            this.controller.StartRace();
        }
        public void RowBoatIsCool()
        {
            //arrange
            RowBoat rowboat = new RowBoat();
            //act

            bool output1 = rowboat.IsCool;

            //assert
            Assert.True(output1);
        }
        public void RowBoatIsReal()
        {
            //arrange
            RowBoat rowboat = new RowBoat();
            //act

            bool output1 = rowboat.IsReal;

            //assert
            Assert.False(output1);
        }
        public void RowBoatCanNotIsReal()
        {
            //arrange
            RowBoat rowboat = new RowBoat();

            //act
            rowboat.IsReal = true;
            bool output1 = rowboat.IsReal;

            //assert
            Assert.True(output1);
        }
        public void RowBoatCanNotHasBow()
        {
            //arrange
            RowBoat rowboat = new RowBoat();

            //act
            rowboat.HasBow = false;
            bool output1 = rowboat.HasBow;

            //assert
            Assert.False(output1);
        }
        public void RowBoatCanNotBeCool()
        {
            //arrange
            RowBoat rowboat = new RowBoat();

            //act
            rowboat.IsCool = false;

            bool output1 = rowboat.IsCool;

            //assert
            Assert.False(output1);
        }
示例#21
0
        public void StartRace_FinishRace_ShouldRemoveCurrentRaceAfterFinish()
        {
            var first  = new RowBoat("rowboat1", 80, 4);
            var second = new RowBoat("rowboat2", 90, 4);
            var third  = new SailBoat("sailboat1", 200, 98);

            this.controller.OpenRace(1000, 10, 5, false);
            this.controller.CurrentRace.AddParticipant(first);
            this.controller.CurrentRace.AddParticipant(second);
            this.controller.CurrentRace.AddParticipant(third);

            this.controller.StartRace();

            Assert.IsNull(this.controller.CurrentRace);
        }
示例#22
0
        static Boat CreateBoat()
        {
            string boatId;
            int    weight, maxSpeed, uniqueProperty;

            switch (random.Next(1, 4 + 1))
            {
            case 1:
                uniqueProperty = random.Next(1, 6 + 1);
                boatId         = CreateBoatId("R-");
                weight         = random.Next(100, 300 + 1);
                maxSpeed       = random.Next(0, 3 + 1);
                Boat rowBoat = new RowBoat(uniqueProperty, boatId, weight, maxSpeed);
                return(rowBoat);

            case 2:
                uniqueProperty = random.Next(10, 1000 + 1);
                boatId         = CreateBoatId("M-");
                weight         = random.Next(200, 3000 + 1);
                maxSpeed       = random.Next(0, 60 + 1);
                Boat motorBoat = new MotorBoat(uniqueProperty, boatId, weight, maxSpeed);
                return(motorBoat);

            case 3:
                uniqueProperty = random.Next(10, 60 + 1);
                boatId         = CreateBoatId("S-");
                weight         = random.Next(800, 6000 + 1);
                maxSpeed       = random.Next(0, 12 + 1);
                Boat sailBoat = new SailBoat(uniqueProperty, boatId, weight, maxSpeed);
                return(sailBoat);

            case 4:
                uniqueProperty = random.Next(0, 500 + 1);
                boatId         = CreateBoatId("C-");
                weight         = random.Next(3000, 20000 + 1);
                maxSpeed       = random.Next(0, 20 + 1);
                Boat cargoBoat = new CargoBoat(uniqueProperty, boatId, weight, maxSpeed);
                return(cargoBoat);

            default:
                return(null);
            }
        }
示例#23
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            {
                _rowBoat = reader.ReadItem() as RowBoat;

                if (_rowBoat == null)
                {
                    Delete();
                }

                break;
            }
            }
        }
示例#24
0
        public void StartRace_BoatWithNegativeTime_ShouldNotFinish()
        {
            var first  = new RowBoat("rowboat1", 80, 4);
            var second = new RowBoat("rowboat2", 90, 4);
            var third  = new SailBoat("sailboat1", 200, 98);

            this.controller.OpenRace(1000, 10, 5, false);
            this.controller.CurrentRace.AddParticipant(first);
            this.controller.CurrentRace.AddParticipant(second);
            this.controller.CurrentRace.AddParticipant(third);

            var distance   = this.controller.CurrentRace.Distance;
            var firstTime  = distance / first.CalculateRaceSpeed(this.controller.CurrentRace);
            var secondTime = distance / second.CalculateRaceSpeed(this.controller.CurrentRace);
            var thirdTime  = distance / third.CalculateRaceSpeed(this.controller.CurrentRace);

            if (thirdTime <= 0)
            {
                thirdTime = double.PositiveInfinity;
            }

            var expected = new StringBuilder();

            expected.AppendLine(string.Format(
                                    "First place: RowBoat Model: rowboat1 Time: {0} sec",
                                    firstTime.ToString("0.00")));
            expected.AppendLine(string.Format(
                                    "Second place: RowBoat Model: rowboat2 Time: {0} sec",
                                    secondTime.ToString("0.00")));
            expected.Append("Third place: SailBoat Model: sailboat1 Time: ");
            expected.Append(double.IsInfinity(thirdTime) ? "Did not finish!" : thirdTime.ToString("0.00"));

            var actual = this.controller.StartRace();

            Assert.AreEqual(expected.ToString(), actual);
        }
示例#25
0
 protected RowBoatItem(RowBoat rowBoat, int northItemID, Point3D initOffset)
     : base(rowBoat, northItemID, initOffset)
 {
     _baseItemID   = northItemID;
     LinkedRowBoat = rowBoat;
 }
示例#26
0
 public RowBoatHelm(RowBoat rowBoat, int northItemID, Point3D initOffset)
     : base(rowBoat, northItemID, initOffset)
 {
     Name = "Wheel";
 }
        public string CreateRowBoat(string model, int weight, int oars)
        {
            IBoat boat = new RowBoat(model, weight, oars);
            this.Database.Boats.Add(boat);

            return string.Format("Row boat with model {0} registered successfully.", model);
        }
示例#28
0
 public LisencedPlayer(ulong userid)
 {
     this.userid = userid;
     rowBoat     = new RowBoat();
     rhibBoat    = new RhibBoat();
 }
示例#29
0
 protected RowBoatItem(RowBoat rowBoat, int northItemID)
     : this(rowBoat, northItemID, Point3D.Zero)
 {
 }