public string RegisterSong(string[] args) { string songName = args[0]; TimeSpan duration = TimeSpan.Parse(args[1]); ISong song = songFactory.CreateSong(songName, duration); return($"Registered song {song.Name} ({duration.Minutes}:{duration.Seconds})"); }
public string RegisterSong(string[] args) { string songName = args[0]; TimeSpan duration = TimeSpan.ParseExact(args[1], timeFormat, CultureInfo.InvariantCulture); ISong song = songFactory.CreateSong(songName, duration); stage.AddSong(song); return($"Registered song {song.Name} ({args[1]})"); }
public string RegisterSong(string[] args) { string name = args[0]; TimeSpan timeSpan = TimeSpan.ParseExact(args[1], TimeFormat, CultureInfo.InvariantCulture); ISong song = songFactory.CreateSong(name, timeSpan); stage.AddSong(song); return($"Registered song {name} ({song.Duration.ToString(TimeFormat)})"); }
public string RegisterSong(string[] args) { string name = args[0]; TimeSpan duration = TimeSpan.Parse("00:" + args[1]); var createdSong = songFactory.CreateSong(name, duration); stage.AddSong(createdSong); return($"Registered song {createdSong.Name} ({createdSong.Duration.ToString(TimeFormat)})"); }
//RegisterSong {name} {mm:ss} public string RegisterSong(string[] args) { string songName = args[0]; TimeSpan duration = TimeSpan.ParseExact(args[1], "mm\\:ss", null); ISong song = songFactory.CreateSong(songName, duration); stage.AddSong(song); return(string.Format(Constants.SongRegistered, song.ToString())); }
public string RegisterSong(string[] args) { var name = args[0]; var timeSpan = args[1].Split(':').Select(int.Parse).ToArray(); var song = songFactory.CreateSong(name, new TimeSpan(0, timeSpan[0], timeSpan[1])); this.stage.AddSong(song); return($"Registered song {song}"); }
public string RegisterSong(string[] args) { var songName = args[0]; var durationArgs = args[1].Split(':'); var minutes = int.Parse(durationArgs[0]); var seconds = int.Parse(durationArgs[1]); var duration = new TimeSpan(0, minutes, seconds); var song = songFactory.CreateSong(songName, duration); this.stage.AddSong(song); return($"Registered song {songName} ({duration:mm\\:ss})"); }
public string RegisterSong(string[] args) { string name = args[0]; string[] time = args[1].Split(':').ToArray(); int minutes = int.Parse(time[0]); int seconds = int.Parse(time[1]); var duration = new TimeSpan(0, 0, minutes, seconds); ISong song = songFactory.CreateSong(name, duration); stage.AddSong(song); return(string.Format($"Registered song {song.Name} ({{duration:{duration.Minutes}\\:{duration.Seconds}}})")); }
public string RegisterSong(string[] args) { string name = args[0]; int[] timeSpanArgs = args[1].Split(':').Select(int.Parse).ToArray(); TimeSpan songDuration = new TimeSpan(0, timeSpanArgs[0], timeSpanArgs[1]); ISong song = songFactory.CreateSong(name, songDuration); this.stage.AddSong(song); return($"Registered song {name} ({songDuration:mm\\:ss})"); }
public string RegisterSong(string[] args) { //Creates a song with the specified name and duration and adds it to the stage’s songs. //Upon successful creation, the command returns "Registered song {songName} ({duration:mm\\:ss})". string name = args[0]; int[] durationArgs = args[1].Split(':').Select(int.Parse).ToArray(); int minutes = durationArgs[0]; int seconds = durationArgs[1]; TimeSpan duration = new TimeSpan(0, minutes, seconds); ISong song = songFactory.CreateSong(name, duration); this.stage.AddSong(song); return($"Registered song {name} ({duration:mm\\:ss})"); }
public string RegisterSong(string[] args) { try { string songName = args[0]; string[] songDuration = args[1].Split(new char[] { ':' }); int minutes = int.Parse(songDuration[0]); int seconds = int.Parse(songDuration[1]); TimeSpan timeSpan = new TimeSpan(0, minutes, seconds); ISong newSong = songFactory.CreateSong(songName, timeSpan); this.stage.AddSong(newSong); return($"Registered song {songName} ({minutes:d2}:{seconds:d2})"); } catch { // not by definition return("ERROR creating song"); } }