diff --git a/csharp-fundamentals-methods.Main/Core.cs b/csharp-fundamentals-methods.Main/Core.cs index a69b542..827c822 100644 --- a/csharp-fundamentals-methods.Main/Core.cs +++ b/csharp-fundamentals-methods.Main/Core.cs @@ -27,7 +27,7 @@ logic. See the example below and take some time to break it down and understand //TODO: 1. Create a method that accepts a name and returns a greeting public string greet(string name) { - throw new NotImplementedException(); + return $"Hello {name}!"; } //TODO: 2. Increment a number @@ -36,7 +36,7 @@ Complete this method so that it increases the number given by 1 and returns the */ public int increment(int number) { - throw new NotImplementedException(); + return number + 1; } //TODO: 3. Construct a friendly greeting @@ -50,7 +50,7 @@ Complete this method so that it accepts a name as an input and outputs a friendl */ public string happilyGreet(string name) { - throw new NotImplementedException(); + return $"Hi, {name} :)"; } @@ -70,9 +70,12 @@ Create a method named constructNumberArray that accepts two whole numbers named public int[] constructNumberArray(int lower, int upper) { - int[] resultArray = { }; - - return resultArray; + int[] resultArray = new int[upper - lower + 1]; + for (int i = 0; i < resultArray.Length; i++) + { + resultArray[i] = lower + i; + } + return resultArray; } @@ -92,7 +95,9 @@ The number of exclamation marks appended must be determined by the number provid public string shout(string phrase, int number) { - return $""; + string upperCasePhrase = phrase.ToUpper(); + string exclamationMarks = new string('!', number); + return upperCasePhrase + exclamationMarks; } diff --git a/csharp-fundamentals-methods.Main/Extension.cs b/csharp-fundamentals-methods.Main/Extension.cs index a4461e2..5a88c39 100644 --- a/csharp-fundamentals-methods.Main/Extension.cs +++ b/csharp-fundamentals-methods.Main/Extension.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; @@ -17,9 +18,23 @@ public class Extension "The cake is still baking!" if there are any remaining minutes left, and "The timer finished ages ago!" if the remaining minutes is a negative number */ - public double timerStatus(int v) + public string timerStatus(int v) { - throw new NotImplementedException(); + string ready = "The cake is ready!"; + string baking = "The cake is still baking!"; + string finished = "The timer finished ages ago!"; + if (v == 0) + { + return ready; + } + else if (v > 0) + { + return baking; + } + else + { + return finished; + } } @@ -35,7 +50,19 @@ provided and the prep time per ingredient. public double estimatePrepTime(string[] strings, int v) { - throw new NotImplementedException(); + + if (v == 0) + { + return strings.Length * 2; + } + else if (v != 0) + { + return strings.Length * v; + } + else + { + return 0; + } } @@ -51,7 +78,17 @@ public double estimatePrepTime(string[] strings, int v) public double calculateGramsOfSugar(string[] strings, int v) { - throw new NotImplementedException(); + int neededsugar = 100; + + if (strings.Contains("sugar") == true) + { + return neededsugar * v; + } + else + { + return 0; + } + }