public IBaseGem Create(IList <string> tokens) { string clarity = tokens[0]; string gemType = tokens[1]; IBaseGem gem = null; switch (gemType) { case "Ruby": gem = new Ruby(clarity); break; case "Emerald": gem = new Emerald(clarity); break; case "Amethyst": gem = new Amethyst(clarity); break; default: throw new ArgumentException("Invalid gem type!"); } return(gem); }
public void AddGem(int socketIndex, IBaseGem gem) { if (SocketExists(socketIndex)) { this.Sockets[socketIndex] = gem; } }
public void ExecuteCommand(IList <string> tokens) { IWeapon currentWeapon = null; IBaseGem currentGem = null; var commandName = tokens[0]; switch (commandName) { case "Create": var weaponInfo = this.inHandler.SplitInput(tokens[1], " "); weaponInfo.Add(tokens[2]); this.weapons.Add(this.weaponFactory.Create(weaponInfo)); break; case "Add": currentWeapon = GetWeapon(tokens[1]); currentGem = this.gemFactory.Create(this.inHandler.SplitInput(tokens[3], " ")); currentWeapon.AddGem(int.Parse(tokens[2]), currentGem); break; case "Remove": currentWeapon = GetWeapon(tokens[1]); currentWeapon.RemoveGem(int.Parse(tokens[2])); break; case "Print": currentWeapon = GetWeapon(tokens[1]); this.outHandler.PrintLine(currentWeapon.ToString()); break; case "Author": this.outHandler.PrintLine(this.weaponAttribute.PrintInfo("Author")); break; case "Revision": this.outHandler.PrintLine(this.weaponAttribute.PrintInfo("Revision")); break; case "Description": this.outHandler.PrintLine(this.weaponAttribute.PrintInfo("Description")); break; case "Reviewers": this.outHandler.PrintLine(this.weaponAttribute.PrintInfo("Reviewers")); break; default: throw new InvalidOperationException($"Command not available: {commandName}"); } }