using System;
public class flavors
{
public static void Main ()
{
string Icecream;
GetFlavor sp = new GetFlavor();
bool isFlavorGood = false;
while (!isFlavorGood)
{
try
{
sp.promptForFlavor();
isFlavorGood = true;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.Writeline("These are the flavors to pick from.");
}
}
}
public class GetFlavor
{
private string[] flavor = {"strawberry", "chocolate"};
public void promtForFlavor()
{
stringstrIcecream;
try
{
Console.WriteLine("What Flavor would you like?");
strIcecream = Console.ReadLine();
//Check if flavor is equal to the string
if (strIcecream != flavor)
{
Console.WriteLine("We don't have that Flavor"};
strIcecream = Console.ReadLine();
}
//else
//{
// Console.WriteLine("Enjoy your icecream.");
//}
}
catch(FormatException fe);
{
throw(fe);
}
}
}
}
Could someone guide me to a website were I can get an example of an exception which uses an array. Without an example I am having a hard time figureing out what statement I am missing in order to correct this issue.

New Topic/Question
Reply




MultiQuote





|