From 8d2ea2d0cb0feb1983cbc4598054e14e2a6fa2a5 Mon Sep 17 00:00:00 2001 From: llllllll-l Date: Wed, 10 Jan 2024 09:05:00 +0100 Subject: [PATCH 1/3] Core done and tested --- csharp-fundamentals-methods.Main/Core.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/csharp-fundamentals-methods.Main/Core.cs b/csharp-fundamentals-methods.Main/Core.cs index a69b542..2a4ea08 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; } //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,7 +70,12 @@ Create a method named constructNumberArray that accepts two whole numbers named public int[] constructNumberArray(int lower, int upper) { - int[] resultArray = { }; + int[] resultArray = new int[upper-lower+1]; + + for (int i = lower; i <= upper; i++) + { + resultArray[i-lower] = i; + } return resultArray; From 86888771492bc6403830d3623be5b5b499d33164 Mon Sep 17 00:00:00 2001 From: llllllll-l Date: Wed, 10 Jan 2024 09:17:17 +0100 Subject: [PATCH 2/3] Core tested and done --- csharp-fundamentals-methods.Main/Core.cs | 4 +++- csharp-fundamentals-methods.Main/Extension.cs | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/csharp-fundamentals-methods.Main/Core.cs b/csharp-fundamentals-methods.Main/Core.cs index 2a4ea08..46f1c50 100644 --- a/csharp-fundamentals-methods.Main/Core.cs +++ b/csharp-fundamentals-methods.Main/Core.cs @@ -97,7 +97,9 @@ The number of exclamation marks appended must be determined by the number provid public string shout(string phrase, int number) { - return $""; + string ex = new string('!', number); + string str = phrase.ToUpper() + ex; + return str; } diff --git a/csharp-fundamentals-methods.Main/Extension.cs b/csharp-fundamentals-methods.Main/Extension.cs index a4461e2..e8b3da4 100644 --- a/csharp-fundamentals-methods.Main/Extension.cs +++ b/csharp-fundamentals-methods.Main/Extension.cs @@ -17,9 +17,10 @@ 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(); + return ""; } From 3732714bbbd9657672e52f1768f9d3b1f33482d5 Mon Sep 17 00:00:00 2001 From: llllllll-l Date: Wed, 10 Jan 2024 09:24:35 +0100 Subject: [PATCH 3/3] Extension done and tested --- csharp-fundamentals-methods.Main/Extension.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/csharp-fundamentals-methods.Main/Extension.cs b/csharp-fundamentals-methods.Main/Extension.cs index e8b3da4..93f764a 100644 --- a/csharp-fundamentals-methods.Main/Extension.cs +++ b/csharp-fundamentals-methods.Main/Extension.cs @@ -20,7 +20,12 @@ public class Extension public string timerStatus(int v) { - return ""; + if (v == 0) return "The cake is ready!"; + else if (v > 0) return "The cake is still baking!"; + else if (v < 0) return "The timer finished ages ago!"; + else return ""; + + } @@ -36,7 +41,14 @@ 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 + { + return strings.Length * v; + } } @@ -52,7 +64,11 @@ public double estimatePrepTime(string[] strings, int v) public double calculateGramsOfSugar(string[] strings, int v) { - throw new NotImplementedException(); + if (strings.Contains("sugar")) + { + return 100 * v; + } + else return 0; }