From 549b41a155e06c7f4172bd5c8883ce2a2457d87d Mon Sep 17 00:00:00 2001 From: Atif Galamov Date: Thu, 9 Jan 2020 16:29:31 +0400 Subject: [PATCH 1/2] Task completed! --- Classes/TimeConverter.cs | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/Classes/TimeConverter.cs b/Classes/TimeConverter.cs index dd5bf4e0..378340f5 100644 --- a/Classes/TimeConverter.cs +++ b/Classes/TimeConverter.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -9,7 +9,40 @@ public class TimeConverter : ITimeConverter { public string convertTime(string aTime) { - throw new NotImplementedException(); + string[] times = aTime.Split(':'); + int hours = int.Parse(times[0]); + int minutes = int.Parse(times[1]); + int seconds = int.Parse(times[2]); + + var clock = seconds % 2 == 0 ? "Y" : "O"; + + // First row + int _5hours = hours / 5; + clock += Environment.NewLine + + new string('R', _5hours) + new string('O', 4 - _5hours); + + // Second row + int _1hours = hours % 5; + clock += Environment.NewLine + + new string('R', _1hours) + new string('O', 4 - _1hours); + + // Third row + int _5minutes = minutes / 5; + + StringBuilder _3rdRow = new StringBuilder( + new string('Y', _5minutes) + + new string('O', 11 - _5minutes)); + _3rdRow[2] = _3rdRow[2] == 'Y' ? 'R' : _3rdRow[2]; + _3rdRow[5] = _3rdRow[5] == 'Y' ? 'R' : _3rdRow[5]; + _3rdRow[8] = _3rdRow[8] == 'Y' ? 'R' : _3rdRow[8]; + clock += Environment.NewLine + _3rdRow; + + // Fourth row + int _1minutes = minutes % 5; + clock += Environment.NewLine + + new string('Y', _1minutes) + new string('O', 4 - _1minutes); + + return clock.ToString(); } } } From 080a60ae492bd23b0e1108b31158a242af12f591 Mon Sep 17 00:00:00 2001 From: Atif Galamov Date: Thu, 9 Jan 2020 16:31:23 +0400 Subject: [PATCH 2/2] Task completed! --- Classes/TimeConverter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/TimeConverter.cs b/Classes/TimeConverter.cs index 378340f5..a65b5642 100644 --- a/Classes/TimeConverter.cs +++ b/Classes/TimeConverter.cs @@ -42,7 +42,7 @@ public string convertTime(string aTime) clock += Environment.NewLine + new string('Y', _1minutes) + new string('O', 4 - _1minutes); - return clock.ToString(); + return clock; } } }