public void MainMenu() { Console.Clear(); Planets p = new Planets(); Console.WriteLine("Where do you want to go? "); p.Menu(); string pick = Console.ReadLine(); int option; while (!int.TryParse(pick, out option)) { p.Menu(); pick = Console.ReadLine(); } if (option >= 1 && option <= 6) { switch (option) { case 1: p.GoldPlanet(); break; case 2: p.SilverPlanet(); break; case 3: p.BrassPlanet(); break; case 4: p.BronzePlanet(); break; case 5: p.CopperPlanet(); break; case 6: HomeMenu(); break; } } else { Console.WriteLine("Invalid number try again."); Console.ReadLine(); MainMenu(); } }
public void PlanetMenu() { GoodyBag g = new GoodyBag(); Planets p = new Planets(); Console.Clear(); Console.WriteLine("What method do you wish to use?"); p.PlanetMenu(); string pick = Console.ReadLine(); int option; while (!int.TryParse(pick, out option)) { p.PlanetMenu(); pick = Console.ReadLine(); } if (option >= 1 && option <= 3) { switch (option) { case 1: Buy(); break; case 2: Sell(); break; case 3: MainMenu(); break; } } else { Console.WriteLine("Invalid number try again."); Console.ReadLine(); PlanetMenu(); } }
public void HomeMenu() { try { Console.Clear(); Planets p = new Planets(); GoodyBag g = new GoodyBag(); Console.WriteLine("Welcome home!!!"); p.HomePlanet(); string pick = Console.ReadLine(); int option; while (!int.TryParse(pick, out option)) { p.HomePlanet(); pick = Console.ReadLine(); } if (option >= 1 && option <= 4) { switch (option) { case 1: Buy(); break; case 2: Sell(); break; case 3: g.CashOut(); break; case 4: MainMenu(); break; } } else { Console.WriteLine("Invalid number try again."); Console.ReadLine(); HomeMenu(); } } catch (FormatException fEx) { Console.WriteLine(fEx.Message); Console.ReadLine(); } catch (InvalidOperationException ioEx) { Console.WriteLine(ioEx.Message); Console.ReadLine(); } catch (OverflowException ofEx) { Console.WriteLine(ofEx.Message); Console.ReadLine(); } catch (DivideByZeroException dZe) { Console.WriteLine(dZe.Message); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadLine(); } finally { Console.WriteLine("This program has finally terminated."); Console.ReadLine(); } }
static void Main(string[] args) { Planets P = new Planets(); P.MainMenu(); }