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 #41

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
112 changes: 99 additions & 13 deletions csharp-fundamentals-control-flow.Main/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,69 +48,113 @@ public string sayGoodMorning(bool isMorning)
// Change the returned value in the method below to your answer. It is case-sensitive.
public string one()
{
return "";
return "Good day!";
}

//TODO: 2. What will the output be if I run sayGoodMorning(true)?
// Change the returned value in the method below to your answer. It is case-sensitive.
public string two()
{
return "";
return "Good morning!";
}

//TODO: 3. What will the output be if I run sayGoodMorning("Hello" == "Hello")?
// Change the returned value in the method below to your answer. It is case-sensitive.
public string three()
{
return "";
return "Good morning!";
}

//TODO: 4. What will the output be if I run sayGoodMorning("A word" != "Another word")
public string four()
{
return "";
return "Good morning!";
}

// 5. What will the output be if I run sayGoodMorning(25 != 25)
public string five()
{
return "";
return "Good day!";
}

//TODO: 6. Use a conditional statement to return "Correct!" if the input is more than 7
// or "Wrong!" if not
public string six(int num)
{
throw new NotImplementedException();
if (num > 7)
{
return "Correct!";
}
else
{
return "Wrong!";
}
}

//TODO: 7. Use a conditional statement to return "Correct!" if the input is false
// or "Wrong!" if not
public string seven(bool boolean)
{
throw new NotImplementedException();

if (!boolean)
{
return "Correct!";
}
else
{
return "Wrong!";
}

}

//TODO: 8. Use a conditional statement to return "Correct!" if numOne is more than or equal to numTwo
// or "Wrong!" if not
public string eight(int numOne, int numTwo)
{
throw new NotImplementedException();

if (numOne >= numTwo)
{
return "Correct!";
}
else
{
return "Wrong!";
}

}

//TODO: 9. Use a conditional statement to return true if the array provided is not empty
// or false if it is empty
public bool nine(int[] nums)
{
throw new NotImplementedException();

if(nums.Length == 0)
{
return false;
}
else
{
return true;
}

}

//TODO: 10. Use a conditional statement to return true if the provided string contains the word
// "milk", or false if not
// https://www.w3schools.com/java/java_ref_string.asp
public bool ten(string sentence)
{
throw new NotImplementedException();

if(sentence.Contains("milk"))
{

return true;
}
else
{
return false;
}

}

//TODO: 11. Use conditional statements to return the number 3 if the provided string contains
Expand All @@ -119,14 +163,36 @@ public bool ten(string sentence)
// Otherwise, return the number 0.
public int eleven(string sentence)
{
throw new NotImplementedException();

if(sentence.Contains("milk") && sentence.Contains("coffee"))
{
return 9;
}
else if (sentence.Contains("coffee"))
{
return 6;
}
else if(sentence.Contains("milk"))
{
return 3;
}
else { return 0; }


}

//TODO: 12. Use conditional statements to return true if num is more than or equal to lower and is
// less than or equal to upper, otherwise return false.
public bool twelve(int num, int lower, int upper)
{
throw new NotImplementedException();

if (num >= lower && num <= upper)
{
return true;
}
else return false;


}

/*
Expand All @@ -141,7 +207,27 @@ public bool twelve(int num, int lower, int upper)
*/
public string thirteen(int age)
{
throw new NotImplementedException();
if (age == 0)
{
return "Baby";
}
else if (age >= 1 && age <= 4)
{
return "Toddler";
}
else if (age >= 5 && age <= 12)
{
return "Child";
}
else if (age >= 13 && age <= 19)
{
return "Teenager";
}
else
{
return "Adult";
}

}
}
}
51 changes: 44 additions & 7 deletions csharp-fundamentals-control-flow.Main/Extension.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace csharp_fundamentals_control_flow.Main
{
Expand All @@ -18,11 +20,26 @@ 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 string timerStatus(int minutes)
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;

}


//TODO: Extension: 2. Create a method named estimatePrepTime that accepts two parameters:
Expand All @@ -35,8 +52,17 @@ provided and the prep time per ingredient.


public int estimatePrepTime(string[] ingredients, int time)
{
throw new NotImplementedException();
{
var elements = ingredients.Count();

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

var prepTime = elements * time;

return prepTime;
}

//TODO: 3. Create a method named calculateGramsOfSugar that accepts two parameters:
Expand All @@ -48,7 +74,18 @@ public int estimatePrepTime(string[] ingredients, int time)

public int calculateGramsOfSugar(string[] ingredients, int time)
{
throw new NotImplementedException();
var sugarAmount = 0;

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

return sugarAmount;
}
}
}
Loading