How can I exit my loop in the main program when the user enters q?
whats the best way to set this up?
i have this class
and this one
whats the best way to set this up?
i have this class
C#:
using System;
namespace HourlyMeetingScheduler
{
class Program
{
static void Main(string[] args)
{
bool programRunning = true;
while (programRunning) {
Utility myUtility = new Utility();
myUtility.WelcomeUser();
myUtility.PrintMainMenu();
myUtility.MainMenuLogic();
}
}
}
}
and this one
C#:
using System;
using System.Collections.Generic;
using System.Text;
namespace HourlyMeetingScheduler
{
class Utility
{
public void WelcomeUser()
{
Console.WriteLine("\nWelcome to the hourly scheduler");
Console.WriteLine("*******************************");
}
public void PrintMainMenu()
{
Console.WriteLine("\nMain Menu");
Console.WriteLine("*********");
Console.WriteLine("\n(a) Add appointment/s");
Console.WriteLine("(r) Remove appointment/s");
Console.WriteLine("(e) Edit appointment/s");
Console.WriteLine("(v) View appointment/s");
Console.WriteLine("(q) quit");
}
public void MainMenuLogic()
{
string userChoice = Console.ReadLine();
char firstLetter = userChoice[0];
switch (firstLetter)
{
case 'a':
AddAppointment();
break;
case 'r':
RemoveAppointment();
break;
case 'e':
EditAppointment();
break;
case 'v':
ViewAppointments();
break;
case 'q':
//quit loop
break;
}
}
}
}