public Electrician CreateHeroe(CompliantHandler handler = null) { if (_electricianFactory == null) { _electricianFactory = new ElectricianFactory(); } var eletrician = (Electrician)_electricianFactory.CreateHeroe(handler); eletrician.Tool = _electricianFactory.CreateTool(); eletrician.Vehicle = _electricianFactory.CreateVehicle(); return(eletrician); }
public Firefighter CreateHeroe(CompliantHandler handler) { if (_fireFighterFactory == null) { _fireFighterFactory = new FireFighterFactory(); } var fireman = (Firefighter)_fireFighterFactory.CreateHeroe(handler); fireman.Tool = _fireFighterFactory.CreateTool(); fireman.Vehicle = _fireFighterFactory.CreateVehicle(); DisplayStrategy(); var success = Int32.TryParse(Console.ReadLine(), out int strategySelect); while (!success || strategySelect >= 3) { Console.Clear(); Console.WriteLine("Wrong option! :( Please try again."); DisplayStrategy(); success = Int32.TryParse(Console.ReadLine(), out strategySelect); } var strategy = (FireFighterStrategyEnum)strategySelect; switch (strategy) { case FireFighterStrategyEnum.Sequential: fireman.ChangeExtinguishStrategy(new SequentialStrategy()); break; case FireFighterStrategyEnum.StairCase: fireman.ChangeExtinguishStrategy(new StaircaseStrategy()); break; case FireFighterStrategyEnum.Spiral: fireman.ChangeExtinguishStrategy(new SpiralStrategy()); break; default: break; } return(fireman); }
public Cop CreateHeroe(CompliantHandler handler = null) { if (_copFactory == null) { _copFactory = new CopFactory(); } var cop = (Cop)_copFactory.CreateHeroe(handler); cop.Tool = _copFactory.CreateTool(); cop.Vehicle = _copFactory.CreateVehicle(); DisplayCommand(); var success = Int32.TryParse(Console.ReadLine(), out int commandSelected); while (!success || commandSelected >= 3) { Console.Clear(); Console.WriteLine("Wrong option! :( Please try again."); DisplayCommand(); success = Int32.TryParse(Console.ReadLine(), out commandSelected); } var strategy = (CommandEnum)commandSelected; switch (strategy) { case CommandEnum.StopRightThere: cop.ChangeOrder(new StopRightThere()); break; case CommandEnum.PursueCriminal: cop.ChangeOrder(new PursueCriminal()); break; case CommandEnum.RequestBackup: cop.ChangeOrder(new RequestBackup()); break; default: break; } return(cop); }
public Medic CreateHeroe(CompliantHandler handler = null) { if (_medicFactory == null) { _medicFactory = new MedicFactory(); } var doctor = (Medic)_medicFactory.CreateHeroe(handler); doctor.Tool = _medicFactory.CreateTool(); doctor.Vehicle = _medicFactory.CreateVehicle(); DisplayCommand(); var success = Int32.TryParse(Console.ReadLine(), out int rcpSelected); while (!success || rcpSelected >= 2) { Console.Clear(); Console.WriteLine("Wrong option! :( Please try again."); DisplayCommand(); success = Int32.TryParse(Console.ReadLine(), out rcpSelected); } var strategy = (RcpEnum)rcpSelected; switch (strategy) { case RcpEnum.RcpTypeA: doctor.Rcp = new RCPTypeA(); break; case RcpEnum.RcpTypeB: doctor.Rcp = new RCPTypeB(); break; default: break; } return(doctor); }
public IResponsable CreateHeroe(CompliantHandler handler = null) { return(new Application.Heroes.Medic(new RCPTypeA(), handler)); }
public IResponsable CreateHeroe(CompliantHandler handler = null) { return(new Cop(heroe: handler)); }
public IResponsable CreateHeroe(CompliantHandler handler = null) { return(new Electrician(handler)); }
public Firefighter(CompliantHandler handler = null) : base(handler) { this.Vehicle = new FireTruck(); this.Tool = new WaterHose(); }
public IResponsable CreateHeroe(CompliantHandler handler) { return(new Firefighter(handler)); }
public Cop(IPoliceOrder command = null, CompliantHandler heroe = null) : base(heroe) { this.command = command ?? new StopRightThere(); this.Vehicle = new PolicePatrolCar(); this.Tool = new Gun(); }
public Electrician(CompliantHandler heroe = null) : base(heroe) { this.Vehicle = new Van(); this.Tool = new Screwdriver(); }
public Medic(RCP rcp, CompliantHandler handler = null) : base(handler) { Rcp = rcp; this.Vehicle = new Ambulance(); this.Tool = new Defibrillator(); }