Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed all tasks #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
15 changes: 10 additions & 5 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,8 @@ Complete this method so that it increases the number given by 1 and returns the
*/
public int increment(int number)
{
throw new NotImplementedException();
number++;
return number;
}

//TODO: 3. Construct a friendly greeting
Expand All @@ -50,7 +51,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 @@ -70,7 +71,7 @@ Create a method named constructNumberArray that accepts two whole numbers named
public int[] constructNumberArray(int lower, int upper)
{

int[] resultArray = { };
int[] resultArray = Enumerable.Range (lower, upper - lower +1).ToArray ();

return resultArray;

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

public string shout(string phrase, int number)
{
return $"";

var upperPhrase = phrase.ToUpper ();
var exclamationMarks = new String('!', number);

return upperPhrase+exclamationMarks;
}


Expand Down
52 changes: 47 additions & 5 deletions csharp-fundamentals-methods.Main/Extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,25 @@ 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 message;

switch(v)
{
case 0:
message = "The cake is ready!"; break;

case > 0:
message = "The cake is still baking!"; break;

case < 0:
message = "The timer finished ages ago!"; break;
}

return message;

}


Expand All @@ -35,12 +51,25 @@ provided and the prep time per ingredient.

public double estimatePrepTime(string[] strings, int v)
{
throw new NotImplementedException();
var elements = strings.Count();

if(v == 0)
{
v = 2;
}

var prepTime = elements * v;

return prepTime;

}



//TODO: Extension 3: calculateGramsOfSugar that accepts two parameters 1 an array of ingredients that will always contain 3 ingredients AND 2 the number of layers the cake has. The cake will need 100g of sugar per layer, if that ingredient is present in the provided list of ingredients. The method should return the number of grams of sugar needed to make the cake.
//TODO: Extension 3: calculateGramsOfSugar that accepts two parameters 1 an array of ingredients that will always contain 3 ingredients
//AND 2 the number of layers the cake has. The cake will need 100g of sugar per layer, if that ingredient is
//present in the provided list of ingredients.
//The method should return the number of grams of sugar needed to make the cake.
/* 3.
Create a method named calculateGramsOfSugar that accepts two parameters:
- an array of ingredients that will always contain 3 ingredients
Expand All @@ -51,7 +80,20 @@ public double estimatePrepTime(string[] strings, int v)

public double calculateGramsOfSugar(string[] strings, int v)
{
throw new NotImplementedException();
var sugarAmount = 0;

if (strings.Contains("sugar"))
{
sugarAmount = 100 * v;
}
else
{
sugarAmount = 0;
}

return sugarAmount;


}


Expand Down
Loading