Ejemplo n.º 1
0
        static void Main(string[] args) //with static you don't need an instance to use a method

        {
            Console.Title = "Math Facts App";
            int choice = 0;
            Addition addTable = new Addition();
            Multiplication timesTable = new Multiplication();
            do //Do While Loop for the whole program
            {
                MainAppTitle();
                choice = MainMenu();
                if (choice == 1)
                {
                    bool continueChoice = true;
                    int startNum = 0;
                    int endNum = 0;
                    do //Do While Loop for the Addition Class
                    {
                        addTable.AdditionTitle();
                        try //Try Catch for starting menu
                        {
                            Console.WriteLine("Enter your starting number");
                            startNum = Int32.Parse(Console.ReadLine());
                            Console.WriteLine("Enter your ending number");
                            endNum = Int32.Parse(Console.ReadLine());
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("Please enter a valid number");
                            Console.ReadLine();
                        }
                        finally
                        {
                            if (startNum > 0 && endNum <= 10)
                            {
                                addTable.AdditionTitle();
                                Console.WriteLine("");
                                Console.ForegroundColor = ConsoleColor.DarkGreen;
                                Console.WriteLine("Your addition Table for {0} - {1}", startNum, endNum);
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.WriteLine("");
                                addTable.AdditionTable(startNum, endNum);
                                Console.WriteLine("");
                                try
                                {
                                    Console.ForegroundColor = ConsoleColor.Green;
                                    Console.WriteLine("Would you like more additon facts [y/n]");
                                    Console.ForegroundColor = ConsoleColor.White;
                                    string moreFacts = Console.ReadLine();
                                    if (moreFacts == "y")
                                    {
                                        continueChoice = true;
                                    }
                                    else if (moreFacts == "n")
                                    {
                                        continueChoice = false;
                                    }
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("");
                                    Console.WriteLine("Enter y or n");
                                }
                            }
                        }

                    } while (continueChoice == true);
                }

                //Multiplication portion
                if (choice == 2)
                {
                    bool continueChoice = true;
                    int startNum = 0;
                    int endNum = 0;
                    do //Do While Loop for the Multiplication Class
                    {
                        timesTable.MultiplicationTitle();
                        try
                        {
                            Console.WriteLine("Enter your starting number");
                            startNum = Int32.Parse(Console.ReadLine());
                            Console.WriteLine("Enter your ending number");
                            endNum = Int32.Parse(Console.ReadLine());
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Please enter a valid number");
                            Console.ReadLine();
                        }
                        finally
                        {
                            if (startNum > 0 & endNum <= 10)
                            {
                                timesTable.MultiplicationTitle();
                                Console.WriteLine("");
                                Console.ForegroundColor = ConsoleColor.Green;
                                Console.WriteLine("Your Multiplication Table for {0} - {1}", startNum, endNum);
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.WriteLine("");
                                timesTable.MultiplicationTable(startNum, endNum);
                                Console.WriteLine("");

                                try
                                {
                                    Console.ForegroundColor = ConsoleColor.Green;
                                    Console.WriteLine("Would you like more multiplication facts [y/n]");
                                    Console.ForegroundColor = ConsoleColor.White;
                                    string moreFacts = Console.ReadLine();
                                    if (moreFacts == "y")
                                    {
                                        continueChoice = true;
                                    }
                                    else if (moreFacts == "n")
                                    {
                                        continueChoice = false;
                                    }
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("");
                                    Console.WriteLine("Enter y or n");
                                }
                            }
                        }
                    } while (continueChoice == true);
                }
            } while (choice != 3);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.Title = "Math Facts App";
            int            choice      = 0;
            Addition       addTable    = new Addition();
            Multiplication timesTable  = new Multiplication();
            Subtraction    minusTable  = new Subtraction();
            Division       divideTable = new Division();

            do
            {
                MainAppTitle();
                choice = MainMenu();
                //TODO = Handle addition choice
                if (choice == 1)
                {
                    bool continueChoice = true;
                    int  startNum       = 0;
                    int  endNum         = 0;
                    //TODO = title
                    do
                    {
                        addTable.AdditionTitle();
                        try
                        {
                            Console.WriteLine("Enter your starting number");
                            startNum = Int32.Parse(Console.ReadLine());
                            Console.WriteLine("Enter your ending number");
                            endNum = Int32.Parse(Console.ReadLine());
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("Please enter a valid number");
                            Console.ReadLine();
                        }
                        finally
                        {
                            //TODO = validate startNum and endNum
                            if (startNum > 0 && endNum <= 10)
                            {
                                addTable.AdditionTitle();
                                Console.WriteLine("");
                                Console.ForegroundColor = ConsoleColor.DarkGreen;
                                Console.WriteLine("Your addition Table for {0} - {1}", startNum, endNum);
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.WriteLine("");
                                addTable.AdditionTitle(startNum, endNum);

                                Console.WriteLine("");
                                try
                                {
                                    Console.ForegroundColor = ConsoleColor.Green;
                                    Console.WriteLine("Would you like more addition facts [y/n]");
                                    Console.ForegroundColor = ConsoleColor.White;
                                    string moreFacts = Console.ReadLine();
                                    if (moreFacts == "y")
                                    {
                                        continueChoice = true;
                                    }
                                    else if (moreFacts == "n")
                                    {
                                        continueChoice = false;
                                    }
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }
                    } while (continueChoice == true);
                }

                if (choice == 2)
                {
                    bool continueChoice = true;
                    int  startNum       = 0;
                    int  endNum         = 0;
                    do
                    {
                        timesTable.MultiplicationTitle();
                        try
                        {
                            Console.WriteLine("Enter your starting number");
                            startNum = Int32.Parse(Console.ReadLine());
                            Console.WriteLine("Enter your ending number");
                            endNum = Int32.Parse(Console.ReadLine());
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Please enter a valid number");
                            Console.ReadLine();
                        }
                        finally
                        {
                            if (startNum > 0 & endNum <= 10)
                            {
                                timesTable.MultiplicationTitle();
                                Console.WriteLine("");
                                Console.ForegroundColor = ConsoleColor.DarkGreen;
                                Console.WriteLine("Your addition Table for {0} - {1}", startNum, endNum);
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.WriteLine("");
                                timesTable.MultiplicationTitle(startNum, endNum);

                                Console.WriteLine("");
                                try
                                {
                                    Console.ForegroundColor = ConsoleColor.Green;
                                    Console.WriteLine("Would you like more addition facts [y/n]");
                                    Console.ForegroundColor = ConsoleColor.White;
                                    string moreFacts = Console.ReadLine();
                                    if (moreFacts == "y")
                                    {
                                        continueChoice = true;
                                    }
                                    else if (moreFacts == "n")
                                    {
                                        continueChoice = false;
                                    }
                                }
                                catch (Exception)
                                {
                                    Console.WriteLine("Please enter a valid number");
                                    Console.ReadLine();
                                }
                            }
                        }
                    } while (continueChoice == true);
                }
                if (choice == 3)
                {
                    bool continueChoice = true;
                    int  startNum       = 0;
                    int  endNum         = 0;
                    //TODO = title
                    do
                    {
                        minusTable.SubtractionTitle();
                        try
                        {
                            Console.WriteLine("Enter your starting number");
                            startNum = Int32.Parse(Console.ReadLine());
                            Console.WriteLine("Enter your ending number");
                            endNum = Int32.Parse(Console.ReadLine());
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("Please enter a valid number");
                            Console.ReadLine();
                        }
                        finally
                        {
                            if (startNum > 0 && endNum <= 10)
                            {
                                minusTable.SubtractionTitle();
                                Console.WriteLine("");
                                Console.ForegroundColor = ConsoleColor.DarkGreen;
                                Console.WriteLine("Your addition Table for {0} - {1}", startNum, endNum);
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.WriteLine("");
                                minusTable.SubtractionTitle(startNum, endNum);

                                Console.WriteLine("");
                                try
                                {
                                    Console.ForegroundColor = ConsoleColor.Green;
                                    Console.WriteLine("Would you like more addition facts [y/n]");
                                    Console.ForegroundColor = ConsoleColor.White;
                                    string moreFacts = Console.ReadLine();
                                    if (moreFacts == "y")
                                    {
                                        continueChoice = true;
                                    }
                                    else if (moreFacts == "n")
                                    {
                                        continueChoice = false;
                                    }
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }
                    } while (continueChoice == true);
                }
                if (choice == 4)
                {
                    bool continueChoice = true;
                    int  startNum       = 0;
                    int  endNum         = 0;
                    //TODO = title
                    do
                    {
                        divideTable.DivisonTitle();
                        try
                        {
                            Console.WriteLine("Enter your starting number");
                            startNum = Int32.Parse(Console.ReadLine());
                            Console.WriteLine("Enter your ending number");
                            endNum = Int32.Parse(Console.ReadLine());
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("Please enter a valid number");
                            Console.ReadLine();
                        }
                        finally
                        {
                            //TODO = validate startNum and endNum
                            if (startNum > 0 && endNum <= 10)
                            {
                                divideTable.DivisonTitle();
                                Console.WriteLine("");
                                Console.ForegroundColor = ConsoleColor.DarkGreen;
                                Console.WriteLine("Your division Table for {0} - {1}", startNum, endNum);
                                Console.ForegroundColor = ConsoleColor.White;
                                Console.WriteLine("");
                                divideTable.DivisionTitle(startNum, endNum);

                                Console.WriteLine("");
                                try
                                {
                                    Console.ForegroundColor = ConsoleColor.Green;
                                    Console.WriteLine("Would you like more division facts [y/n]");
                                    Console.ForegroundColor = ConsoleColor.White;
                                    string moreFacts = Console.ReadLine();
                                    if (moreFacts == "y")
                                    {
                                        continueChoice = true;
                                    }
                                    else if (moreFacts == "n")
                                    {
                                        continueChoice = false;
                                    }
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }
                    } while (continueChoice == true);
                }
            } while (choice != 5);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            Console.Title = "Math Facts App";
            int            choice     = 0;
            Addition       addTable   = new Addition();
            Multiplication timesTable = new Multiplication();

            do
            {
                MainAppTitle();
                Console.WriteLine();
                choice = MainMenu();

                if (choice == 1)
                {
                    bool continueChoice = true;
                    int  startNum       = 0;
                    int  endNum         = 0;

                    do
                    {
                        addTable.AdditionTitle();
                        try
                        {
                            Console.WriteLine("Enter your starting number: ");
                            startNum = Int32.Parse(Console.ReadLine());
                            Console.WriteLine("Enter your ending number: ");
                            endNum = Int32.Parse(Console.ReadLine());
                        }
                        catch (FormatException)
                        {
                            Console.WriteLine("Please enter a valid number");
                            Console.ReadLine();
                        }
                        finally
                        {
                            if (startNum > 0 && endNum <= 10)
                            {
                                addTable.AdditionTitle();
                                Console.WriteLine("");
                                Console.ForegroundColor = ConsoleColor.DarkCyan;
                                Console.WriteLine("Your addition Table for {0} - {1}:", startNum, endNum);
                                Console.WriteLine("");
                                addTable.AdditionTable(startNum, endNum);

                                Console.WriteLine("");
                                try
                                {
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("Would you like more addition facts? [y/n]");
                                    Console.ForegroundColor = ConsoleColor.White;
                                    string moreFacts = Console.ReadLine();
                                    if (moreFacts == "y")
                                    {
                                        continueChoice = true;
                                    }
                                    else if (moreFacts == "n")
                                    {
                                        continueChoice = false;
                                    }
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                            Console.ReadLine();
                            continueChoice = false;
                        }
                    } while (continueChoice == true);
                }

                if (choice == 2)
                {
                    bool continueChoice = true;
                    int  startNum       = 0;
                    int  endNum         = 0;
                    do
                    {
                        timesTable.MultiplicationTitle();
                        try
                        {
                            Console.WriteLine("Enter your starting number:");
                            startNum = Int32.Parse(Console.ReadLine());
                            Console.WriteLine("Enter your ending number:");
                            endNum = Int32.Parse(Console.ReadLine());
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Please enter a valid number.");
                            Console.ReadLine();
                        }
                        finally
                        {
                            if (startNum > 0 && endNum <= 10)
                            {
                                timesTable.MultiplicationTitle();
                                Console.WriteLine("");
                                Console.ForegroundColor = ConsoleColor.DarkCyan;
                                Console.WriteLine("Your multiplication Table for {0} - {1}:", startNum, endNum);
                                Console.WriteLine("");
                                timesTable.MultiplicationTable(startNum, endNum);

                                Console.WriteLine("");

                                try
                                {
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("Would you like more multiplication facts? [y/n]");
                                    Console.ForegroundColor = ConsoleColor.White;
                                    string moreFacts = Console.ReadLine();
                                    if (moreFacts == "y")
                                    {
                                        continueChoice = true;
                                    }
                                    else if (moreFacts == "n")
                                    {
                                        continueChoice = false;
                                    }
                                }
                                catch (Exception)
                                {
                                    throw;
                                }
                            }
                        }
                    } while (continueChoice == true);
                }
            } while (choice != 3);
        }