Example #1
0
 [Test] //Test 4
 public void CannotCreateBoatWithNegativePrice()
 {
     Assert.Catch(() =>
     {
         Motorboat Baywatch = new Motorboat("Baywatch", -25000, 60);
     });
 }
Example #2
0
 [Test] //Test 2
 public void SpeedCannotBeNegative()
 {
     Assert.Catch(() =>
     {
         Motorboat Baywatch = new Motorboat("Baywatch", 25000, -60);
     });
 }
Example #3
0
        [Test] //Test 7
        public void EnhancedSpeedIsTwiceAsBig()
        {
            Motorboat Baywatch = new Motorboat("Baywatch", 25000, 60);

            Assert.IsTrue(Baywatch.Speed == 60);
            Baywatch.EnhanceSpeed();
            Assert.IsTrue(Baywatch.Speed == 120);
        }
Example #4
0
        [Test] //Test 6
        public void CanChangePriceAfterwards()
        {
            Motorboat Baywatch = new Motorboat("Baywatch", 25000, 60);

            Assert.IsTrue(Baywatch.Price == 25000);
            Baywatch.Price = 26000;
            Assert.IsTrue(Baywatch.Price == 26000);
        }
Example #5
0
        [Test] //Test 5
        public void CanChangeSpeedAfterwards()
        {
            Motorboat Titanic = new Motorboat("Titanic", 45000, 60);

            Assert.IsTrue(Titanic.Speed == 60);
            Titanic.Speed = 100;
            Assert.IsTrue(Titanic.Speed == 100);
        }
Example #6
0
        static void Main(string[] args)
        {
            Motorboat Titanic  = new Motorboat("Titanic", 45000, 50);
            Motorboat Baywatch = new Motorboat("Baywatch", 25000, 60);

            Console.WriteLine("Titanic's speed: {0}", Titanic.Speed);
            Console.WriteLine("Baywatch's price: {0}", Baywatch.Price);
            Baywatch.Price = 26000;
            Console.WriteLine("Baywatch's price after resetting: {0}", Baywatch.Price);
            Titanic.EnhanceSpeed();
            Console.WriteLine("Titanic's speed after doubling: {0}", Titanic.Speed);

            Rowboat Speedy = new Rowboat("Speedy", 1500, 2);

            Console.WriteLine("Speedy's price: {0}", Speedy.Price);

            //Task 3.4: array

            Console.WriteLine("array:");

            IBoat[] array = new IBoat[] { Titanic, Baywatch, Speedy };

            foreach (var i in array)
            {
                Console.WriteLine("boat {0}: after using enhance speed method: {1}", i.Name, i.EnhanceSpeed());
            }

            //Task 4.2: serialization

            Console.WriteLine("serialization:");

            foreach (var i in array)
            {
                string jsonstring = JsonConvert.SerializeObject(i);
                Console.WriteLine(jsonstring);
            }
        }
Example #7
0
    public static void Main()
    {
        // create some vehicles using the vehicle classes
        JetSki              StriperJetSki     = new JetSki();
        Motorboat           LargeMotorboat    = new Motorboat(12);
        Motorboat           FastMotorboat     = new Motorboat(8, 6.1);
        Sailboat            LumberingSailBoat = new Sailboat();
        Motorcycle          ZippyMotorcycle   = new Motorcycle();
        SportsCar           LeMansSportsCar   = new SportsCar();
        SportUtilityVehicle Rover             = new SportUtilityVehicle();
        Cessna              TravelingCessna   = new Cessna();
        Boeing747           AirFrance         = new Boeing747();
        HangGlider          SeeingBrazil      = new HangGlider();


        // Build a collection of all vehicles that fly
        List <IVehicleAir> flyingVehicles = new List <IVehicleAir>()
        {
            TravelingCessna,
            AirFrance,
            SeeingBrazil
        };

        // With a single `foreach`, have each vehicle Fly()
        foreach (IVehicleAir vehicle in flyingVehicles)
        {
            vehicle.Fly();
        }


        // Build a collection of all vehicles that operate on roads
        List <IVehicleLand> landVehicles = new List <IVehicleLand>()
        {
            ZippyMotorcycle,
            LeMansSportsCar,
            Rover
        };

        // With a single `foreach`, have each road vehicle Drive()
        foreach (IVehicleLand vehicle in landVehicles)
        {
            vehicle.Drive();
        }


        // Build a collection of all vehicles that operate on water
        List <IWaterDrive> waterVehicles = new List <IWaterDrive>()
        {
            StriperJetSki,
            LumberingSailBoat,
            LargeMotorboat,
            FastMotorboat
        };

        // With a single `foreach`, have each water vehicle Drive()
        foreach (IWaterDrive vehicle in waterVehicles)
        {
            vehicle.Drive();
        }

        // check to see if my overloaded constructor functions for the Motorboat class work
        Console.WriteLine($"LargeMotorboat passenger capacity: {LargeMotorboat.PassengerCapacity}");
        Console.WriteLine($"FastMotorboat Passenger Capacity: {FastMotorboat.PassengerCapacity} Engine Volume: {FastMotorboat.EngineVolume}");
    }
Example #8
0
        [Test] //Test 1
        public void CanCreateNewBoat()
        {
            Motorboat Titanic = new Motorboat("Titanic", 45000, 50);

            Assert.IsTrue(Titanic.Name == "Titanic" && Titanic.Price == 45000 && Titanic.Speed == 50);
        }