protected override void ExecuteInsertPerformerCommand(string[] commandWords) { switch (commandWords[2]) { case "band": var band = new Band(commandWords[3]); this.InsertPerformer(band); break; default: base.ExecuteInsertPerformerCommand(commandWords); break; } }
private string GetBandReport(Band band) { StringBuilder bandInfo = new StringBuilder(); bandInfo.Append(band.Name + ": "); if (band.Members.Any()) { bandInfo.Append(string.Join(", ", band.Members)); } if (band.Songs.Any()) { var songs = band.Songs .Select(s => s.Title) .OrderBy(s => s); bandInfo.AppendLine().Append(string.Join("; ", songs)); } else { bandInfo.AppendLine().Append("no songs"); } return bandInfo.ToString(); }
private string GetBandReport(Band band) { StringBuilder bandReport = new StringBuilder(); bandReport.AppendFormat(band.Name + ":"); if (band.Members.Count != 0) { bandReport.AppendFormat(" "); int count = 0; for (int i = 0; i < band.Members.Count; i++) { if (count == 0) { bandReport.AppendFormat(band.Members[i]); count++; } else { bandReport.AppendFormat(", {0}", band.Members[i]); } } } if (band.Songs.Count == 0) { bandReport.AppendLine().AppendFormat("no songs"); } else { bandReport.AppendLine(); int count = 0; var sortedSongs = from currentSong in band.Songs orderby currentSong.Title select currentSong.Title; foreach (var songTitle in sortedSongs) { if (count == 0) { bandReport.AppendFormat(songTitle); count++; } else { bandReport.AppendFormat("; {0}", songTitle); } } } return bandReport.ToString(); }