diff --git a/Classes/TimeConverter.cs b/Classes/TimeConverter.cs index dd5bf4e0..19e8d76a 100644 --- a/Classes/TimeConverter.cs +++ b/Classes/TimeConverter.cs @@ -1,7 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Globalization; +using Microsoft.VisualBasic; namespace BerlinClock { @@ -9,7 +8,20 @@ public class TimeConverter : ITimeConverter { public string convertTime(string aTime) { - throw new NotImplementedException(); + var berlimClockArray = new string[5]; + var aTimeArray = aTime.Split(':'); + var fourthRowPattern = "YYRYYRYYRYY"; + var hours = Convert.ToInt32(aTimeArray[0]); + var minutes = Convert.ToInt32(aTimeArray[1]); + var seconds = Convert.ToInt32(aTimeArray[2]); + + berlimClockArray[0] = seconds % 2 == 0 ? "Y" : "O"; + berlimClockArray[1] = new String('R', hours / 5).PadRight(4, 'O'); + berlimClockArray[2] = new String('R', hours % 5).PadRight(4, 'O'); + berlimClockArray[3] = fourthRowPattern.Substring(0, minutes / 5).PadRight(fourthRowPattern.Length, 'O'); + berlimClockArray[4] = new String('Y', minutes % 5).PadRight(4, 'O'); + + return String.Join(Environment.NewLine, berlimClockArray); } } }