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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System; //<-- Added using statement to solve Task 1.


namespace CodeLou.CSharp.Week2.Challenge
{
Expand All @@ -16,7 +16,7 @@ static void Main(string[] args)
// Hint: In Visual Studio, you can build the project by selecting "Build Solution" from the
// build menu, or by pressing <Ctrl>+<Shift>+B.
Console.WriteLine("Welcome to the Code Louisville C# week 2 code challenge!");
Console.WriteLine("Press <Enter> to begin..."); //<-- Added semicolon to solve Task 2.
Console.WriteLine("Press <Enter> to begin...")
Console.ReadLine();

Console.WriteLine("This is the launch application for the first human mission to Mars.");
Expand All @@ -26,22 +26,15 @@ static void Main(string[] args)
// Capture the number of seconds that the user would like to count down before liftoff.
// Hint: You should use another method of the Console class and store the output into a
// variable to use later.
var strNumSeconds = Console.ReadLine(); //<-- Captured user input into variable to solve Task 3.


// Task 4:
// Write a condition to test whether the number that they entered is less than or equal to zero.
// Call the IsLessThanOrEqualToZero() method below, passing the user's number as a parameter.
// If the result is true, write "Please enter a positive number." to the console.
// Hint: The input that you captured is currently a string type. You will have to "parse" it
// as a different type in order to pass it to the IsLessThanOrEqualToZero function.
int iNumSeconds;
if (!int.TryParse(strNumSeconds, out iNumSeconds) || IsLessThanOrEqualToZero(iNumSeconds))
{
//In the line above, we're testing to see if the input was both numeric, and positive. The same
//validation message is applicable in either case. Sometimes, you might want want to be more
//specific about the nature of the invalid data, to be more user-friendly.
Console.WriteLine("Please enter a positive number.");
}


// Task 5:
// Add an "else" block to the condition from Task 4. This should be run in the case that the
Expand All @@ -51,15 +44,6 @@ static void Main(string[] args)
// "for". You can choose whichever you'd like to solve the task. The Microsoft
// Developer Network (MSDN) website contains all of the documentation for C#. If you want
// to learn more about loops, visit https://msdn.microsoft.com/en-us/library/32dbftby.aspx.
else
{
for (var i = iNumSeconds; i > 0; i--)
{
Console.WriteLine(i);
System.Threading.Thread.Sleep(1000); //<-- Pause execution for one second.
}
Console.WriteLine("LIFTOFF!");
}

Console.WriteLine("Press <Enter> to exit...");
Console.ReadLine();
Expand Down