MovieTimes Console App

[code language=”csharp”] using System;
using static System.Console;

/// <summary>
/// # # # # # # # # # # # # #
/// # Mark Hesser #
/// # Jan 25, 18 #
/// # Movie Running Time #
/// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
/// # Instructions: #
/// # Write a program named Movie that contains a method that accepts and displays two parameters: a string name of a movie and an #
/// # integer running time in minutes. Provide a default value for the minutes so that if you call the method without an integer argument, #
/// # minutes is set to 90. Write a Main() method that proves you can call the movie method with only a string argument as well as with a #
/// # string and an integer #
/// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
/// </summary>
namespace MovieTimes
{
class Movie
{
static void Main(string[] args)
{
#region Declarations
string movie;
int runtime = 0;
bool quit = false;
#endregion

Title = "Movie Times";

while (!quit)
{
Clear();
WriteLine(" Please Enter a Movie Title as well as the total running time, in minutes. " +
"\n If no time is provided the default \"90\" will be used");
Write("\n Movie: ");
movie = ReadLine();
Write(" Running Time: ");

//This checks the input and sets anything other than a number to zero.
Int32.TryParse(ReadLine(), out runtime);

//If zero is entered into the runtime, it calls the DisplayMovie method with only the movie string.
if (runtime == 0)
DisplayMovie(movie);
//Otherwise, call the DisplayMovie Method with the movie string and override the default runtime.
else
DisplayMovie(movie, runtime);

Quit(ref quit);
}

}

/// <summary>
/// This Method accepts a string parameter and displays it with the default runtime of 90 minutes.
/// </summary>
/// <param name="Movie"></param>
/// <param name="RunTime"></param>
static void DisplayMovie(string Movie, int RunTime = 90)
{
WriteLine("\n The movie \"{0}\" has a running time of {1} minutes", Movie, RunTime);
}

/// <summary>
/// This Method asks the user if they would like to enter another movie.
/// </summary>
static void Quit(ref bool quit)
{
ConsoleKeyInfo kb;
//Asks the user if they would like to enter another movie.
Write("\n Would you like to enter another Movie? (y/n) ");
kb = ReadKey(); //Listens for Key
if (kb.Key == ConsoleKey.N) //Ends the Program
{
quit = true;
}
else if (kb.Key == ConsoleKey.Y)
{
quit = false;
}
else //Tells the User they are stupid and then Quits the program
{
WriteLine("\n You didn’t hit Y or N. " +
"\n I’m going to assume you said No. " +
"\n Press Any Key Quit…\a");
ReadKey();
quit = true; //Ends Program
}
}
}
}
[/code]