Пример #1
0
    public void DoSomethingWithCars()
    {
        var builder  = new FerrariBuilder();
        var director = new SportsCarBuildDirector(builder);

        director.Construct();
        Car myRaceCar = builder.GetResult();
    }
Пример #2
0
        static void Main(string[] args)
        {
            var builder  = new FerrariBuilder();
            var director = new SportsCarBuildDirector(builder);

            director.Construct();
            Car myRaceCar = builder.GetResult();
        }
Пример #3
0
        public void ShouldBuildAFerrari()
        {
            var builder  = new FerrariBuilder();
            var director = new SportCarBuildDirector(builder);

            director.Construct();
            Car ferrari = builder.GetResult();

            ferrari.Color.Should().BeEquivalentTo("Red");
            ferrari.NumDoors.Should().Be(2);
            ferrari.Make.Should().BeEquivalentTo("Ferrari");
            ferrari.Model.Should().BeEquivalentTo("488 Spider");
        }
Пример #4
0
        public static void Main()
        {
            ICarBuilder            ferrariBuilder  = new FerrariBuilder();
            SportsCarBuildDirector ferrariDirector = new SportsCarBuildDirector(ferrariBuilder);

            ferrariDirector.Construct();

            Car ferrari1 = ferrariBuilder.GetResult();
            Car ferrari2 = ferrariBuilder.GetResult();

            Console.WriteLine($"The cars brand is a {ferrari1.brand} and it's colour is {ferrari1.colour}");


            ICarBuilder            lamborghiniBuilder  = new LamborghiniBuilder();
            SportsCarBuildDirector lamborghiniDirector = new SportsCarBuildDirector(lamborghiniBuilder);

            lamborghiniDirector.Construct();

            Car lamborghini1 = lamborghiniBuilder.GetResult();
            Car lamborghini2 = lamborghiniBuilder.GetResult();

            Console.WriteLine($"The cars brand is a {lamborghini1.brand} and it's colour is {lamborghini1.colour}");
        }
        public void Ferrari_RedTwoDoors_IsTrue()
        {
            //arrange
            var builder  = new FerrariBuilder();
            var director = new SportscarBuilderDirector(builder);
            var colour   = "Red";
            var numboors = 2;

            //act
            director.Construct(colour, numboors);
            var MyCar = builder.GetResult();

            //Assert
            Assert.IsTrue((MyCar.Make.Equals("Ferrari") && MyCar.Model.Equals("488 Spider") && MyCar.Colour.Equals(colour) && MyCar.NumDoors == numboors));
        }
Пример #6
0
        public static void Main(string[] args)
        {
            var builder     = new FerrariBuilder();
            var corvBuilder = new CorvetteBuilder();
            var director    = new SportscarBuilderDirector(builder);
            var director2   = new SportscarBuilderDirector(corvBuilder);

            director.Construct("Red", 2);
            director2.Construct("Black", 2);
            Car MyCar      = builder.GetResult();
            Car MyCorvette = corvBuilder.GetResult();

            Console.WriteLine($"Marke: {MyCar.Make}, Model: {MyCar.Model}, Farbe: {MyCar.Colour}, Türen: {MyCar.NumDoors}");
            Console.WriteLine($"Marke: {MyCorvette.Make}, Model: {MyCorvette.Model}, Farbe: {MyCorvette.Colour}, Türen: {MyCorvette.NumDoors}");
            Console.ReadLine();
        }
Пример #7
0
        public void Start()
        {
            // Create director and builders

            Director director = new Director();

            Builder b1 = new FerrariBuilder();
            Builder b2 = new ChevroletBuilder();

            // Construct two products

            director.Construct(b1);
            Car car1 = b1.GetResult();

            car1.Show();

            director.Construct(b2);
            Car car2 = b2.GetResult();

            car2.Show();
        }