From 50cf9ff182bdc0429181bb1471743ddaa86e4d43 Mon Sep 17 00:00:00 2001 From: Tonnes Date: Mon, 27 Jan 2025 11:51:58 +0100 Subject: [PATCH] Done --- csharp-fundamentals-methods.Main/Core.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/csharp-fundamentals-methods.Main/Core.cs b/csharp-fundamentals-methods.Main/Core.cs index aad1694..6d6e38e 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} :)"; } //TODO: 4. Construct an array of numbers @@ -67,7 +67,11 @@ 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 = 0; i < upper-lower+1; i++) + { + resultArray[i] = lower + i; + } return resultArray; } @@ -86,7 +90,12 @@ The number of exclamation marks appended must be determined by the number provid public string shout(string phrase, int number) { - return $""; + string resPhrase = phrase.ToUpper(); + for (int i = 0; i < number; i++) + { + resPhrase = resPhrase + "!"; + } + return resPhrase; } } }