diff --git a/csharp-fundamentals-methods.Main/Core.cs b/csharp-fundamentals-methods.Main/Core.cs index a69b542..c3991b0 100644 --- a/csharp-fundamentals-methods.Main/Core.cs +++ b/csharp-fundamentals-methods.Main/Core.cs @@ -27,7 +27,9 @@ 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(); + //throw new NotImplementedException(); + string defaultGreeting = "Hello "; + return defaultGreeting + name + "!"; } //TODO: 2. Increment a number @@ -36,7 +38,9 @@ Complete this method so that it increases the number given by 1 and returns the */ public int increment(int number) { - throw new NotImplementedException(); + //throw new NotImplementedException(); + int numberToReturn = number + 1; + return numberToReturn; } //TODO: 3. Construct a friendly greeting @@ -50,7 +54,11 @@ Complete this method so that it accepts a name as an input and outputs a friendl */ public string happilyGreet(string name) { - throw new NotImplementedException(); + //throw new NotImplementedException(); + string defaultGreeting = "Hi, "; + string endOfGreeting = " :)"; + + return defaultGreeting + name + endOfGreeting; } @@ -69,11 +77,14 @@ Create a method named constructNumberArray that accepts two whole numbers named public int[] constructNumberArray(int lower, int upper) { + int[] resultArray = new int[upper - lower +1]; - int[] resultArray = { }; + for (int i =0; i 0) + { + return "The cake is still baking!"; + } + else if (v < 0) + { + return "The timer finished ages ago!"; + } + else + { + return "The cake is ready!"; + } } @@ -35,7 +48,18 @@ provided and the prep time per ingredient. public double estimatePrepTime(string[] strings, int v) { - throw new NotImplementedException(); + //throw new NotImplementedException(); + int preptimePerIngredient = v; + + if (preptimePerIngredient == 0) + { + preptimePerIngredient = 2; + } + + int totalPrepTime = strings.Length * preptimePerIngredient; + + return totalPrepTime; + } @@ -51,7 +75,21 @@ public double estimatePrepTime(string[] strings, int v) public double calculateGramsOfSugar(string[] strings, int v) { - throw new NotImplementedException(); + //throw new NotImplementedException(); + int numberOfLayers = v; + string sugar = "sugar"; + int sugarGrams = 100 * numberOfLayers; + + if (Array.Exists(strings, element => element == sugar)) + { + return sugarGrams; + } + else + { + return 0; + } + + }