void Connect() { try { if ((String)cmbPorts.SelectedItem != "Simulator") { if (bicycle != null) { bicycle.Disconnect(); } bicycle = new Bicycle(cmbPorts.SelectedItem.ToString()); } else { if (bicycle != null) { bicycle.Disconnect(); } bicycle = new Simulator(300); } bicycle.ResetDevice(); bicycle.RequestCommandMode(); bicycle.RequestTime("0705"); } catch (Exception e) { MessageBox.Show(e.Message); } }
/// <summary> /// Creates a new instance /// </summary> public BicycleComponentsCollection(IBicycle parent) { this._parent = parent; parent.FrameChanged += this.HandleValueChange; parent.ForkChanged += this.HandleValueChange; parent.Wheels.AsNotifiable().CollectionChanged += this.HandleCollectionChange; parent.HandleBarChanged += this.HandleValueChange; }
private static void TouringBike() { AbstractRoadBike roadBike = new Touring(BikeColor.Gold, new NarrowWheel(12)); BikeBuilder builder = new RoadBikeBuilder(roadBike); BikeDirector director = new RoadBikeDirector(); IBicycle bicycle = director.Build(builder); Console.WriteLine(bicycle); }
static void BuilderDemo() { AbstractMoutainBike moutainBike = new DownHill(new WideWheel(24), BikeColor.Red); BikeBuilder builder = new MountainBikeBuilder(moutainBike); BikeDirector director = new MountainBikeDirector(); IBicycle bicycle = director.Build(builder); Console.WriteLine(bicycle); }
private static void BuilderPatterDemo() { AbstractMountainBike mountainBike = new Downhill(BikeColor.Green, new Widewheel(24)); BikeBuilder builder = new MountainBikeBuilder(mountainBike); //builde object BikeDirector director = new MountainBikeDirector(); // diector object IBicycle bicycle = director.Build(builder); // interface object Console.WriteLine(bicycle); }
private static void BuilderPatternDemo() { AbstractMountainBike mountainBike = new Downhill(BikeColor.Gold, new WideWheel(32)); BikeBuilder builder = new MountainBikeBuilder(mountainBike); BikeDirector director = new MountainBikeDirector(); IBicycle bicycle = director.Build(builder); Console.WriteLine(bicycle); }
private static void VintageBike() { AbstractRoadBike vintageRoadBike = new Vintage(BikeColor.Ocean, new NarrowWheel(10)); BikeBuilder builder = new RoadBikeBuilder(vintageRoadBike); BikeDirector director = new RoadBikeDirector(); IBicycle bicycle = director.Build(builder); Console.WriteLine(bicycle); }
public void PrepareForSale(IBicycle bicycle) { Registration reg = new Registration(bicycle); reg.AllocateBikeNumber(); Documentation.PrintBrochure(bicycle); bicycle.CleanFrame(); bicycle.AirTire(); bicycle.TestRide(); }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.Model == null)) { IBicycle modelCasted = item.As <IBicycle>(); if ((modelCasted != null)) { this._parent.Model = modelCasted; return; } } }
//Builder Design Pattern Demo Method private static void BuilderPatternDemo() { /*Object instance of AbstractMountainBike created using its child class Downhill. * Its constructor takes 2 arguments*/ AbstractMountainBike mountainBike = new Downhill(BikeColor.Green, new WideWheel(24)); /*Both BikeBuilder and BikeDirector object instances are created. * Build passes the object above into its constructor*/ BikeBuilder builder = new MountainBikeBuilder(mountainBike); BikeDirector director = new MountainBikeDirector(); /*Interface object of IBicycle is assigned the value of the Build method called from the * BikeDirector object above. Its output is displayed on the console*/ IBicycle bicycle = director.Build(builder); Console.WriteLine(bicycle); }
public static void PrintBrochure(IBicycle bicycle) { Console.WriteLine("printing brochure..."); }
public CustomGripOption(IBicycle bicycle) : base(bicycle) { }
public WhiteTiresOption(IBicycle bicycle) : base(bicycle) { }
public GoldFrameOption(IBicycle bicycle) : base(bicycle) { }
public WhiteTires(IBicycle bicycle) : base(bicycle) { }
public static void PrintBrochure(IBicycle bicycle) { Console.WriteLine("Printing Brochure"); }
public BicycleAsCar(IBicycle bicycle) { this.bicycle = bicycle; }
public GoldFrame(IBicycle bicycle) : base(bicycle) { }
public WhiteTireOptions(IBicycle bicycle) : base(bicycle) { }
/*Constructor that takes 1 parameter. Also passes the value to its parent through the base declaration * Below this is a constructor*/ public AbstractBikeOption(IBicycle bicycle) : base(BikeColor.Chrome, bicycle.GetWheel) { this.decoratedBike = bicycle; }
public BicyclesController(IBicycle ibicycle, ICategory icategory) { allbicycle = ibicycle; allcategory = icategory; }
public LeatherSeat(IBicycle bicycle) : base(bicycle) { }
public CustomGrip(IBicycle bicycle) : base(bicycle) { }
public Registration(IBicycle bicycle) { this._bicycle = bicycle; }
public AbstractBikeOption(IBicycle bicycle) : base(bicycle.Wheel, BikeColor.Black) { this.decoratedBike = bicycle }
public LeatherSheetOption(IBicycle bicycle) : base(bicycle) { }
public HomeController(IBicycle bicycleRep) { _bicycleRep = bicycleRep; }
public ShopCartController(IBicycle bicycleRep, ShopCart shopCart) { _bicycleRep = bicycleRep; _shopCart = shopCart; }