public string ToggleFighterAggressiveMode(string fighterName) { if (this.machines.FirstOrDefault(n => n.Name == fighterName && n.GetType().Name == "Fighter") != null) { IFighter wantedFighter = (Fighter)this.machines.FirstOrDefault(n => n.Name == fighterName && n.GetType().Name == "Fighter"); wantedFighter.ToggleAggressiveMode(); return($"Fighter {wantedFighter.Name} toggled aggressive mode"); } return($"Machine {fighterName} could not be found"); }
public string ToggleFighterAggressiveMode(string fighterName) { if (machines.Any(t => t.GetType().Name == nameof(Fighter) && t.Name == fighterName)) { IFighter fighter = (Fighter)machines.FirstOrDefault(t => t.GetType().Name == nameof(Tank) && t.Name == fighterName); fighter?.ToggleAggressiveMode(); return(String.Format(OutputMessages.FighterOperationSuccessful, fighterName)); } return(String.Format(OutputMessages.MachineNotFound, fighterName)); }
public string ToggleFighterAggressiveMode(string fighterName) { IFighter fighterToToggle = (IFighter)this.machines.FirstOrDefault(t => t.Name == fighterName); if (fighterToToggle == null) { return(string.Format(OutputMessages.MachineNotFound, fighterName)); } fighterToToggle.ToggleAggressiveMode(); return(string.Format(OutputMessages.FighterOperationSuccessful, fighterToToggle.Name)); }
public string ToggleFighterAggressiveMode(string fighterName) { IFighter fighter = fighters.FirstOrDefault(x => x.Name == fighterName); if (fighter.Name == fighterName) { fighter.ToggleAggressiveMode(); return(string.Format(OutputMessages.FighterOperationSuccessful, fighterName)); } return(string.Format(OutputMessages.MachineNotFound, fighterName)); }
public string ToggleFighterAggressiveMode(string fighterName) { if (this.machines.Any(name => name.Name == fighterName)) { IMachine machine = machines.FirstOrDefault(f => f.Name == fighterName); IFighter fighter = (IFighter)machine; fighter.ToggleAggressiveMode(); return(string.Format(OutputMessages.FighterOperationSuccessful, fighterName)); } return(string.Format(OutputMessages.MachineNotFound, fighterName)); }
public string ToggleFighterAggressiveMode(string fighterName) { if (this.machines.FirstOrDefault(m => m.Name == fighterName && m.GetType().Name == nameof(Fighter)) == null) { return(string.Format(OutputMessages.MachineNotFound, fighterName)); } IFighter fighter = (Fighter)this.machines.FirstOrDefault(m => m.Name == fighterName && m.GetType().Name == nameof(Fighter)); fighter.ToggleAggressiveMode(); return(string.Format(OutputMessages.FighterOperationSuccessful, fighter.Name)); }
public string ToggleFighterAggressiveMode(string fighterName) { if (machines.Any(m => m.Name == fighterName && m.GetType().Name == "Fighter")) { IFighter tank = (IFighter)machines.Where(m => m.Name == fighterName && m.GetType().Name == "Fighter").First(); tank.ToggleAggressiveMode(); return(string.Format(OutputMessages.FighterOperationSuccessful, fighterName)); } else { return(string.Format(OutputMessages.MachineNotFound, fighterName)); } }
public string ToggleFighterAggressiveMode(string fighterName) { IFighter fighter = machines.FirstOrDefault(m => m.Name == fighterName) as Fighter; if (fighter == null) { return(string.Format(OutputMessages.MachineNotFound, fighterName)); } fighter.ToggleAggressiveMode(); return(string.Format(OutputMessages.FighterOperationSuccessful, fighterName)); }
public string ToggleFighterAggressiveMode(string fighterName) { if (!machines.ContainsKey(fighterName)) { return(string.Format(OutputMessages.MachineNotFound, fighterName)); } IFighter fighter = (IFighter)machines[fighterName]; fighter.ToggleAggressiveMode(); return(string.Format(OutputMessages.FighterOperationSuccessful, fighterName)); }
public string ToggleFighterAggressiveMode(string fighterName) { IFighter machine = (IFighter)this.machines.FirstOrDefault(x => x.Name == fighterName && x is IFighter); if (machine == null) { return($"Machine {fighterName} could not be found"); } else { machine.ToggleAggressiveMode(); return($"Fighter {fighterName} toggled aggressive mode"); } }
public string ToggleFighterAggressiveMode(string fighterName) { if (this.machines.ContainsKey(fighterName)) { IMachine machine = this.machines[fighterName]; IFighter fighter = machine as IFighter; fighter.ToggleAggressiveMode(); return($"Fighter {fighterName} toggled aggressive mode"); } return($"Machine {fighterName} could not be found"); }
public string ToggleFighterAggressiveMode(string fighterName) { IMachine machine = this.machines.FirstOrDefault(m => m.Name == fighterName); if (machine == null) { return($"Machine {fighterName} could not be found"); } IFighter fighter = (IFighter)machine; fighter.ToggleAggressiveMode(); return($"Fighter {fighterName} toggled aggressive mode"); }
public string ToggleFighterAggressiveMode(string fighterName) { IFighter machine = (IFighter)this.machines .FirstOrDefault(f => f.Name == fighterName && f.GetType().Name == "Fighter"); if (machine == null) { return(string.Format(OutputMessages.MachineNotFound, fighterName)); } else { machine.ToggleAggressiveMode(); return(string.Format(OutputMessages.FighterOperationSuccessful, fighterName)); } }
public string ToggleFighterAggressiveMode(string fighterName) { var fighter = this.machines.FirstOrDefault(f => f.Name == fighterName); if (fighter == null) { return($"Machine {fighterName} could not be found"); } IFighter fighter1 = (IFighter)fighter; fighter1.ToggleAggressiveMode(); return($"Fighter {fighterName} toggled aggressive mode"); }
public string ToggleFighterAggressiveMode(string fighterName) { string result = string.Empty; IMachine machine = machines.FirstOrDefault(m => m.Name == fighterName); if (machine != null) { IFighter fighter = (IFighter)machine; fighter.ToggleAggressiveMode(); result = $"Fighter {fighterName} toggled aggressive mode"; } else { result = $"Machine {fighterName} could not be found"; } return(result); }
public string ToggleFighterAggressiveMode(string fighterName) { IMachine machine = machines.FirstOrDefault(f => f.Name == fighterName && f is Fighter); if (machine is null) { return(string.Format(OutputMessages.MachineNotFound, fighterName)); } else { IFighter fighter = machine as Fighter; fighter.ToggleAggressiveMode(); return(string.Format(OutputMessages.FighterOperationSuccessful, fighterName)); } }
public string ToggleFighterAggressiveMode(string fighterName) { var searchedFighter = this.machines .FirstOrDefault(m => m.Name == fighterName && m.GetType().Name == nameof(Fighter)); if (searchedFighter == null) { result = string.Format(OutputMessages.MachineNotFound, fighterName); } else { IFighter fighter = (IFighter)searchedFighter; fighter.ToggleAggressiveMode(); result = string.Format(OutputMessages.FighterOperationSuccessful, fighterName); } return(result); }
public string ToggleFighterAggressiveMode(string fighterName) { IFighter fighter = (Fighter)this.machines .FirstOrDefault(f => f.Name == fighterName && f.GetType() == typeof(Fighter)); if (fighter is null) { return(string.Format( OutputMessages.MachineNotFound, fighterName)); } fighter.ToggleAggressiveMode(); return(string.Format( OutputMessages.FighterOperationSuccessful, fighterName)); }
public string ToggleFighterAggressiveMode(string fighterName) { if (!CheckIfMachineExists(fighterName)) { return(string.Format(OutputMessages.MachineNotFound, fighterName)); } IMachine machine = GetMachine(fighterName); if (!(machine is IFighter)) { return(string.Format(OutputMessages.MachineNotFound, fighterName)); } else { IFighter fighter = machine as IFighter; fighter.ToggleAggressiveMode(); return(string.Format(OutputMessages.FighterOperationSuccessful, fighterName)); } }
public string ToggleFighterAggressiveMode(string fighterName) { string result = string.Empty; IMachine foundMachine = this.machines .FirstOrDefault(t => t.Name == fighterName); if (foundMachine != null) { IFighter currentFighter = (IFighter)foundMachine; currentFighter.ToggleAggressiveMode(); result = string.Format(OutputMessages.FighterOperationSuccessful, currentFighter.Name); } else { result = string.Format(OutputMessages.MachineNotFound, fighterName); } return(result); }