public string AddDecoration(string decorationType) { if (decorationType != "Plant" && decorationType != "Ornament") { throw new InvalidOperationException("Invalid decoration type."); } if (decorationType == "Plant") { decorations.Add(new Plant()); } else if (decorationType == "Ornament") { decorations.Add(new Ornament()); } return($"Successfully added {decorationType}."); }
public string AddDecoration(string decorationType) { if (decorationType == "Ornament") { decorations.Add(new Ornament()); } else if (decorationType == "Plant") { decorations.Add(new Plant()); } else { throw new InvalidOperationException(ExceptionMessages.InvalidDecorationType); } return(String.Format(OutputMessages.SuccessfullyAdded, decorationType)); }
public string AddDecoration(string decorationType) { switch (decorationType) { case "Ornament": decorations.Add(new Ornament()); break; case "Plant": decorations.Add(new Plant()); break; default: throw new InvalidOperationException(ExceptionMessages.InvalidDecorationType); } return(string.Format(OutputMessages.SuccessfullyAdded, decorationType)); }
public string AddDecoration(string decorationType) { if (decorationType == "Ornament") { IDecoration currentDecoration = new Ornament(); decorations.Add(currentDecoration); return($"Successfully added {decorationType}."); } else if (decorationType == "Plant") { IDecoration currentDecoration = new Plant(); decorations.Add(currentDecoration); return($"Successfully added {decorationType}."); } else { throw new InvalidOperationException(ExceptionMessages.InvalidDecorationType); } }
public string AddDecoration(string decorationType) { IDecoration decoration; if (decorationType == nameof(Ornament)) { decoration = new Ornament(); } else if (decorationType == nameof(Plant)) { decoration = new Plant(); } else { throw new InvalidOperationException(ExceptionMessages.InvalidDecorationType); } decorations.Add(decoration); return string.Format(OutputMessages.SuccessfullyAdded, decorationType); }
public string AddDecoration(string decorationType) { IDecoration decoration = null; if (decorationType == nameof(Ornament)) { decoration = new Ornament(); } else if (decorationType == nameof(Plant)) { decoration = new Plant(); } else { throw new InvalidOperationException("Invalid decoration type."); } decorationRepository.Add(decoration); return($"Successfully added {decorationType}."); }
public string AddDecoration(string decorationType) { IDecoration currentDecoration = null; if (decorationType == "Ornament") { currentDecoration = new Ornament(); } else if (decorationType == "Plant") { currentDecoration = new Plant(); } else { throw new InvalidOperationException(ExceptionMessages.InvalidDecorationType); } decorationRepository.Add(currentDecoration); return(string.Format(OutputMessages.SuccessfullyAdded, decorationType)); }
public string AddDecoration(string decorationType) { IDecoration dec = null; if (decorationType == "Ornament") { dec = new Ornament(); } if (decorationType == "Plant") { dec = new Plant(); } if (dec == null) { throw new InvalidOperationException(ExceptionMessages.InvalidDecorationType); } decorations.Add(dec); return($"Successfully added {decorationType}."); }
public string AddDecoration(string decorationType) { decorations.Add(Factory.CreateObject <IDecoration>(decorationType, ExceptionMessages.InvalidDecorationType)); return(string.Format(OutputMessages.SuccessfullyAdded, decorationType)); }