static void Main(string[] args)
        {
            HouseBoat o = new HouseBoat();

            o.HoldHouseParty();
            o.DoBoatRace();
        }
示例#2
0
        // Implementation in Homework4
        private static void BuilderPatternDemo()
        {
            AbstractPleasureBoat pleasureBoat = new HouseBoat(new InboardEngine(400), BoatColor.Forrest_Green);
            BoatBuilder          builder      = new PleasureBoatBuilder(pleasureBoat);
            BoatDirector         director     = new PleasureBoatDirector();
            IBoat boat = director.Build(builder);

            Console.WriteLine(boat);
        }
示例#3
0
        static void Main()
        {
            var car1 = new HondaCivic();
            var car2 = new BMW(true);
            var car3 = new NissanLeaf(true);

            var Cars = new List <Car>();

            Cars.Add(car1);
            Cars.Add(car2);
            Cars.Add(car3);

            foreach (var car in Cars)
            {
                car.Driving();
            }

            var plane1 = new WrightFlyer();
            var plane2 = new SupermarineSpitfire();
            var plane3 = new BlériotXI();

            var planes = new List <Aircraft>();

            planes.Add(plane1);
            planes.Add(plane2);
            planes.Add(plane3);

            foreach (var plane in planes)
            {
                plane.Flying();
            }

            var boat1 = new FishingBoat();
            var boat2 = new Canoe();
            var boat3 = new HouseBoat();

            var boats = new List <Watercraft>();

            boats.Add(boat1);
            boats.Add(boat2);
            boats.Add(boat3);

            foreach (var boat in boats)
            {
                boat.Driving();
            }
        }
示例#4
0
        // Implementation in Homework4
        private static void DecoratorPatternDemo()
        {
            IBoat myBassBoat = new Bass(new OutboardEngine(200), BoatColor.Metallic_Grey);

            Console.WriteLine(myBassBoat);

            myBassBoat = new FishFinderGear(myBassBoat);
            Console.WriteLine(myBassBoat);

            IBoat myPontoonBoat = new Pontoon(new InboardEngine(350), BoatColor.Metallic_Grey);

            Console.WriteLine(myPontoonBoat);

            myPontoonBoat = new RefrigerationUnit(myPontoonBoat);
            Console.WriteLine(myPontoonBoat);

            IBoat myHouseBoat = new HouseBoat(new InboardEngine(550), BoatColor.Sandstone_Brown);

            Console.WriteLine(myHouseBoat);

            myHouseBoat = new EntertainmentCenter(myHouseBoat);
            Console.WriteLine(myHouseBoat);
        }