Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions csharp-fundamentals-methods.Main/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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} :)";
}


Expand All @@ -69,11 +69,13 @@ Create a method named constructNumberArray that accepts two whole numbers named

public int[] constructNumberArray(int lower, int upper)
{

int[] resultArray = { };

List<int> result = new List<int>();
for(int i = lower; i <= upper; i++)
{
result.Add(i);
}
int[] resultArray = result.ToArray();
return resultArray;

}


Expand All @@ -92,7 +94,15 @@ The number of exclamation marks appended must be determined by the number provid

public string shout(string phrase, int number)
{
return $"";
phrase = phrase.ToUpper();
StringBuilder sb = new StringBuilder();
sb.Append(phrase);
for(int i = 0; i < number; i++)
{
sb.Append("!");
}

return $"{sb}";
}


Expand Down