private static void MakeMeABoatAbstractFactoryPattern() { string whatToMake = "Sail Boat"; AbstractBoatFactory factory = null; IBoatColor boatColor = null; if (whatToMake.Equals("Sail Boat")) { factory = new SailBoatFactory(); boatColor = factory.CreateBoatColor("Blue", true); } else { factory = new MotorBoatFactory(); boatColor = factory.CreateBoatColor("Green", false); } IBoatBody boatBody = factory.CreateBoatBody(); IBoatMotor boatMotor = factory.CreateBoatMotor(); //Show what was created Console.WriteLine(boatBody.BoatBodyStyle); Console.WriteLine(boatMotor.MotorSize); Console.WriteLine(boatColor.BoatColor); }
private static void AbstractBoatFactoryPattern() { string whatToBuild = "sailboat hull"; AbstractBoatFactory factory = null; if (whatToBuild.Equals("sailboat hull")) { factory = new SailBoatFactory(); } else { factory = new MotorBoatFactory(); } IBoatHull boatHull = factory.CreateBoatHull(); IBoatMotor boatMotor = factory.CreateBoatMotor(); Console.WriteLine(boatHull.BoatHullParts); Console.WriteLine(boatMotor.BoatMotorParts); }
public AbstractMotorBoat(IBoatMotor engine, IBoatColor color, IBoatBody body) : base(engine, color, body) { }
public SailBoat(IBoatMotor engine, IBoatColor color, IBoatBody body) : base(engine, color, body) { }
public AbstractBoat(IBoatMotor engine, IBoatColor color, IBoatBody body) { _engine = engine; _boatColor = color; _body = body; }