/*
         * IEnumerable - A List, Array, String, Query implements IEnumerable.
         * An IEnumerable Interface specifies that the underlying type implements IEnumerable
         *
         * public Interface IEnumerator
         * {
         * bool MoveNext();
         * object Current {get;}
         * void Reset();
         * }
         *
         * public interface IEnumerable
         * {
         * IEnumerator GetEnumerator();
         * }
         *
         * Note! - Notice the interfaces inherited by String, it uses IEnumerable<char> and not IEnumerable<string>
         * public sealed class String : IComparable, ICloneable, IConvertible, IComparable<String>, IEnumerable<char>,
         *                            IEnumerable, IEquatable<String>
         *
         */
        public static void Menu()
        {
            int x = 0;

            do
            {
                Console.Clear();
                Console.WriteLine(" IEnumerator Interface \n ");
                Console.WriteLine(" 0.  IEnumeratorString01 \n ");
                Console.WriteLine(" 1.  IENumeratorString02 \n ");
                Console.WriteLine(" 9.  Quit            \n\n ");
                Console.Write(" Enter Number to execute Routine ");

                eMenu selection = (eMenu)(Common.readInt("Enter Number to Execute Routine : ", 0, 9));
                switch (selection)
                {
                case eMenu.IENumeratorString01:
                    IEnumaratorString01();
                    break;

                case eMenu.IENumeratorString02:
                    IEnumaratorString02();
                    break;

                case eMenu.Quit:
                    x = 9;
                    break;

                default: Console.WriteLine(" Invalid Number");
                    break;
                }
            } while (x < 9);
        }  // End Menu
示例#2
0
        public static eMenu getItem(Byte IdMenu)
        {
            SqlCommand cmd = new SqlCommand("pADM_Menu_select");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@IdMenu", SqlDbType.TinyInt).Value = IdMenu;
            SqlDataReader reader = ExecuteReader(cmd);

            eMenu oMenu = null;

            if (reader.Read())
            {
                oMenu             = new eMenu();
                oMenu.IdMenu      = reader.GetByte(0);
                oMenu.Descripcion = reader.GetString(1);
                oMenu.Activo      = reader.GetBoolean(2);
                if (!reader[3].Equals(DBNull.Value))
                {
                    oMenu.Posicion = reader.GetByte(3);
                }
            }
            reader.Close();

            return(oMenu);
        }
示例#3
0
        public static List <eMenu> GetList()
        {
            SqlCommand cmd = new SqlCommand("pADM_Menu_list");

            cmd.CommandType = CommandType.StoredProcedure;
            //cmd.Parameters.Add("@IdMenu", SqlDbType.Int).Value = oMenu.IdMenu;

            SqlDataReader reader = ExecuteReader(cmd);
            List <eMenu>  lMenu  = new List <eMenu>();

            while (reader.Read())
            {
                eMenu oMenu = new eMenu();

                oMenu.IdMenu      = reader.GetByte(0);
                oMenu.Descripcion = reader.GetString(1);
                oMenu.Activo      = reader.GetBoolean(2);
                oMenu.Posicion    = reader.GetByte(3);

                lMenu.Add(oMenu);
            }
            reader.Close();

            return(lMenu);
        }
示例#4
0
    public void SwitchMenu(eMenu menu)
    {
        float fadeTime = 0.2f;

        switch (menu)
        {
        case eMenu.Login:
            _activeMenu.Deactivate(fadeTime);
            _login.Activate(fadeTime);
            _activeMenu = _login;
            break;

        case eMenu.Register:
            _activeMenu.Deactivate(fadeTime);
            _register.Activate(fadeTime);
            _activeMenu = _register;
            break;

        case eMenu.Recover:
            _activeMenu.Deactivate(fadeTime);
            break;

        case eMenu.CharacterCreate:
            _activeMenu.Deactivate(fadeTime);
            _create.Activate(fadeTime);
            _activeMenu = _create;
            break;

        case eMenu.Game:
            _activeMenu.Deactivate(fadeTime);
            _gameMain.Activate(fadeTime);
            _activeMenu = _gameMain;
            break;
        }
    }
示例#5
0
        private static void displayGarageMenu()
        {
            string userInput;
            int    validOption;
            string licencePlate = string.Empty;
            bool   exitProgram  = false;

            while (!exitProgram)
            {
                Console.WriteLine(MessagesEnglish.k_GarageOptionsMessage);
                userInput = Console.ReadLine();
                Ex02.ConsoleUtils.Screen.Clear();
                while (!InputValidation.IsValidEnumInput(userInput, Enum.GetNames(typeof(eMenu)).Length, out validOption))
                {
                    Console.WriteLine(MessagesEnglish.k_InvalidInputMessage);
                    Console.WriteLine(MessagesEnglish.k_GoingBackToMainMenuMessage);
                    Thread.Sleep(2000);
                    Ex02.ConsoleUtils.Screen.Clear();
                    Console.WriteLine(MessagesEnglish.k_GarageOptionsMessage);
                    userInput = Console.ReadLine();
                    Ex02.ConsoleUtils.Screen.Clear();
                }

                eMenu userOption = (eMenu)validOption;

                if (!(userOption.Equals(eMenu.DisplayVehiclesInGarage) || userOption.Equals(eMenu.Exit)))
                {
                    licencePlate = enterLicencePlate();
                }

                sentToUserChoice(licencePlate, userOption);
            }
        }
示例#6
0
        public static int Insert(eMenu oMenu)
        {
            SqlCommand cmd = new SqlCommand("pADM_Menu_insert");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@Descripcion", SqlDbType.VarChar, 50).Value = oMenu.Descripcion;
            cmd.Parameters.Add("@Activo", SqlDbType.Bit).Value = oMenu.Activo;

            return(InsertCommand(cmd, true));
        }
示例#7
0
        public static int Update(eMenu oMenu)
        {
            SqlCommand cmd = new SqlCommand("pADM_Menu_update");

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@IdMenu", SqlDbType.TinyInt).Value          = oMenu.IdMenu;
            cmd.Parameters.Add("@Descripcion", SqlDbType.VarChar, 50).Value = oMenu.Descripcion;
            cmd.Parameters.Add("@Activo", SqlDbType.Bit).Value = oMenu.Activo;

            return(UpdateCommand(cmd));
        }
        public int Menu_add(eMenu oMenu)
        {
            int addNew = 0;

            IdException = cMenu.Insert(oMenu);
            if (IdException == 0)
            {
                addNew = cMenu.getLastID;
            }

            return(addNew);
        }
        public bool Menu_edit(eMenu oMenu)
        {
            bool isEdit = false;

            IdException = cMenu.Update(oMenu);
            if (IdException == 0)
            {
                isEdit = true;
            }

            return(isEdit);
        }
示例#10
0
        private static void sentToUserChoice(string i_LicencePlate, eMenu i_UserOption)
        {
            try
            {
                switch (i_UserOption)
                {
                case eMenu.AddNewVehicle:
                    addNewVehicle(i_LicencePlate);
                    break;

                case eMenu.DisplayVehiclesInGarage:
                    displayVehiclesInGarage();
                    break;

                case eMenu.ChangeCarStatus:
                    changeVehicleStatus(i_LicencePlate);
                    break;

                case eMenu.FillAir:
                    fillAir(i_LicencePlate);
                    break;

                case eMenu.Refuel:
                    reFuel(i_LicencePlate);
                    break;

                case eMenu.Recharge:
                    reCharge(i_LicencePlate);
                    break;

                case eMenu.DisplayVehicleDetails:
                    displayVehicleDetails(i_LicencePlate);
                    break;

                case eMenu.Exit:
                    exitProgram();
                    break;

                default:
                    Console.WriteLine(MessagesEnglish.k_InvalidInputMessage);
                    Console.WriteLine(MessagesEnglish.k_GoingBackToMainMenuMessage);
                    Thread.Sleep(2000);
                    break;
                }
            }
            catch (ArgumentException ae)
            {
                Console.WriteLine(ae.Message + Environment.NewLine + MessagesEnglish.k_GoingBackToMainMenuMessage);
                Thread.Sleep(2000);
                Ex02.ConsoleUtils.Screen.Clear();
            }
        }
示例#11
0
        public static bool UserChoice(eMenu i_Choice)
        {
            switch (i_Choice)
            {
            case eMenu.AddVehicle:
                AddNewCar();
                break;

            case eMenu.DisplayLicensePlates:
                DisplayAllLicensesPlates();
                break;

            case eMenu.DisplayFilteredLicensePlates:
                DisplayFilteredLicensesPlates();
                break;

            case eMenu.ChangeVehicleState:
                ChangeVehicleStateInGarage();
                break;

            case eMenu.PumpVehicleWheels:
                PumpVehicleWheels();
                break;

            case eMenu.AddFuelToVehicle:
                AddFuel();
                break;

            case eMenu.LoadElectricVehicle:
                LoadElectric();
                break;

            case eMenu.DisplayVehicleDetails:
                DisplayAllDetails();
                break;

            case eMenu.Exit:
                m_Exit = true;
                break;

            default:
                break;
            }

            return(m_Exit);
        }
    private bool isExistingMainMenuOption(eMenu i_MenuChoice)
    {
        bool isExistChoice = true;

        switch (i_MenuChoice)
        {
        case eMenu.PlayGame:
            this.configureGameScreen();
            break;

        case eMenu.Exit:
            Console.WriteLine("Have a good day.");
            break;

        default:
            isExistChoice = false;
            break;
        }

        return(isExistChoice);
    }
        public static void Menu()
        {
            int x = 0;

            do
            {
                Console.Clear();
                Console.WriteLine(" Enumerable Methods Menu - Deferred vs Immediate Operators\n ");
                Console.WriteLine(" 0.  IENumerator Interface / Website \n ");
                Console.WriteLine(" 1.  Immediate Operators (ToArray, ToList, ToDictionary, ToLookup )\n ");
                Console.WriteLine(" 2.  Deferred Operators (select, where, take, skip)  \n");
                Console.WriteLine(" 9.  Quit            \n\n ");
                Console.Write(" Enter Number to execute Routine ");

                eMenu selection = (eMenu)(Common.readInt("Enter Number to Execute Routine : ", 0, 9));
                switch (selection)
                {
                case eMenu.IENumerator:
                    IEnumeratorInterface.Menu();
                    break;

                case eMenu.Immediate:
                    EnumerableImmmediateMethods.Menu();
                    break;

                case eMenu.Deferred:
                    LINQExamples.Menu();
                    break;

                case eMenu.Quit:
                    x = 9;
                    break;

                default: Console.WriteLine(" Invalid Number");
                    break;
                }
            } while (x < 9);
        }  // End Menu
示例#14
0
 public Menor(string nombre, string apellido, eMenu menu)
     : this(nombre, apellido)
 {
     this._menu = menu;
 }
示例#15
0
        static void Main(string[] args)
        {
            try
            {
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                //////////////////////////////////////// Блок тестирования работоспособности методов //////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                //тестовый массив объектов класса Book
                //Book[] bTestArr = { new Book(new Author("A", "a"), "TitA", 11.11f), new Book(new Author("B", "b"), "TitB", 22.22f),
                //                    new Book(new Author("C", "c"), "TitC", 33.33f), new Book(new Author("D", "d"), "TitD", 44.44f),
                //                    new Book(new Author("E", "e"), "TitE", 55.55f), new Book(new Author("F", "f"), "TitF", 66.66f),
                //                    new Book(new Author("G", "g"), "TitG", 77.77f), new Book(new Author("H", "h"), "TitH", 88.88f),
                //                    new Book(new Author("I", "i"), "TitI", 99.99f), new Book(new Author("J", "j"), "TitJ", 10.10f),};

                //тестовый массив объектов класса Book с переставленнымы элементами для тестирования сортировки по названию (Book.SearchBookToAutho())
                //Book[] bTestArr2 ={ new Book(new Author("A", "a"), "TitA", 11.11f), new Book(new Author("I", "i"), "TitI", 99.99f),
                //                    new Book(new Author("E", "e"), "TitE", 55.55f), new Book(new Author("D", "d"), "TitD", 44.44f),
                //                    new Book(new Author("C", "c"), "TitC", 33.33f), new Book(new Author("F", "f"), "TitF", 66.66f),
                //                    new Book(new Author("H", "h"), "TitH", 88.88f), new Book(new Author("G", "g"), "TitG", 77.77f),
                //                    new Book(new Author("B", "b"), "TitB", 22.22f), new Book(new Author("J", "j"), "TitJ", 10.10f),};


                //Book.SearchBookByAuthor("H", bTestArr);//проверка работоспособности поиска по фамилии автора

                //проверка работоспособности сортировки по названию
                //Book.ShowArr(bTestArr2);
                //Book.SortByTitle(bTestArr2);
                //Book.ShowArr(bTestArr2);

                //проверка работоспособности удаления по цене
                //Book.ShowArr(bTestArr);
                //Book.DeletByCost(55.55f, ref bTestArr);
                //Book.ShowArr(bTestArr);
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                int iArrSize = 0;//для ввода раозмера массива

                do
                {
                    Console.Write("Enter the size of the array of books:"); //просим ввести размер массива
                    iArrSize = Convert.ToInt32(Console.ReadLine());         //вводим и преобразовываем ввод
                    if (iArrSize > 0 && iArrSize < int.MaxValue)            //если размер отрицательный или слишком большой просим ввести еще раз
                    {
                        break;
                    }
                } while (true);

                Book[] boArr = new Book[iArrSize]; //создаём массив введенного размера

                Book.EnterArr(ref boArr);          //заполнение массива

                //начало работы меню
                do
                {
                    //предлагаемые действия
                    Console.WriteLine(new String('*', 75));
                    Console.WriteLine("1 - Search by author's name\n2 - Sort by book's title\n3 - Delet by book's cost\nAny other input - Exit ");
                    Console.Write("Select an action:");
                    eMenu eSelAct = (eMenu)Convert.ToInt32(Console.ReadLine());//ввод и преобразование выбора действия
                    switch (eSelAct)
                    {
                    //если выброн поиск по имени просим ввести имя и запускаем поиск
                    case eMenu.searToAuth:
                        Console.Write("Enter author's name(only Surname):");
                        Book.SearchBookByAuthor(Console.ReadLine(), boArr);
                        break;

                    //если выбрана сортировка запускаем сортировку и показываем результат на консоль
                    case eMenu.sortToTitl:
                        Book.SortByTitle(boArr);
                        Console.WriteLine("Sort List:");
                        Book.ShowArr(boArr);
                        break;

                    //если выбрано удаление по цене просим ввести цену и запускаем метод удаления
                    case eMenu.delToCost:
                        Console.Write("Enter book's cost(format XX,XX):");
                        float fCost = 0f;
                        if (!float.TryParse(Console.ReadLine(), out fCost))
                        {
                            Console.WriteLine("Error enter cost");
                        }
                        else
                        {
                            Book.DeletByCost(fCost, ref boArr);
                        }
                        break;

                    //при любом другом вводе завершаем программу
                    default:
                        return;
                    }
                } while (true);
            }//конец общего try
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.Read();
            }
        } //конец Main
示例#16
0
        public static void Menu()
        {
            int x = 0;

            do
            {
                /*
                 *  Every method has zero or more parameters
                 *  Use params keyword to accept a variable number of parameters
                 *  The params parameter must be the last parameter in a parameter list
                 *  The params keyworkd must be applied to an array modifiers.
                 *  The params parameter must always be the last modifier.
                 *
                 *  Example
                 *  private void WriteDebug(string message, params object[] objects)
                 *  {
                 *     Debug.WriteLine(message);
                 *     foreach (var o in objects)
                 *     {
                 *       Debug.WriteLine(o);
                 *     }
                 *
                 *  }
                 *
                 */
                Console.Clear();
                Console.WriteLine(" Methods Menu \n ");
                Console.WriteLine(" 0.  Constructors and Finalizers \n ");
                Console.WriteLine(" 1.  Overloading \n ");
                Console.WriteLine(" 2.  Parameters and Extension Methods\n");
                Console.WriteLine(" 3.  ... \n");
                Console.WriteLine(" 4.  User Defined Conversions \n");
                Console.WriteLine(" 5.  ....");
                Console.WriteLine(" 6.  GetProperty Method \n");
                Console.WriteLine(" 7.  Class versus Struct \n");
                Console.WriteLine(" 9.  Quit            \n\n ");
                Console.Write(" Enter Number to execute Routine ");

                eMenu selection = (eMenu)(Common.readInt("Enter Number to Execute Routine : ", 0, 9));
                switch (selection)
                {
                case eMenu.ConstructorsandFinalizers:
                    ConstructorsFinalizers();
                    break;

                case eMenu.Overloading:
                    overloadingsub();
                    break;

                case eMenu.Parameters:
                    Parameters();
                    break;

                //case eMenu.Pinvoke:
                //    PreProcessing();
                //    break;

                //case eMenu.EnumerableMethods:
                //    EnumerableMethods.Menu();
                //    Console.ReadKey();

                //    break;

                case eMenu.GetPropertyMethods:
                    MyTypeClass.MainMTC();
                    Console.ReadKey();
                    break;

                case eMenu.ClassVsStruct:
                    // TestClassAndStruct.TCAS_Main();
                    Struct1.Menu();
                    Console.ReadKey();
                    break;

                case eMenu.Quit:
                    x = 9;
                    break;

                default: Console.WriteLine(" Invalid Number");
                    break;
                }
            } while (x < 9);
        }  // End Menu
        private void functionOfGarage(string i_UserChoice)
        {
            m_eUserMenuChoice = (eMenu)Enum.Parse(typeof(eMenu), i_UserChoice);

            switch (m_eUserMenuChoice)
            {
            case eMenu.NewVehicle:
            {
                addNewVehicle();
                break;
            }

            case eMenu.ShowListOfVehicles:
            {
                listOfVehicles();
                break;
            }

            case eMenu.ChangeVeihcleSituation:
            {
                changeVehicleSituation();
                break;
            }

            case eMenu.MaxAirWheelsPressure:
            {
                changeAirPressureToMax();
                break;
            }

            case eMenu.RefuelFuelEnginVehicle:
            {
                refuleVhicle();
                break;
            }

            case eMenu.RechargeElectricEngineVehicle:
            {
                chargeElectricVehicle();
                break;
            }

            case eMenu.ShowAllVeihcleDetails:
            {
                printOwnersVehicleDetails();
                break;
            }

            case eMenu.ExitProgram:
            {
                Console.WriteLine("Good bye!");
                // $G$ NTT-999 (-1) You should avoid brutally terminating the process. (The program can end in the regular flow).
                Environment.Exit(0);
                break;
            }

            default:
            {
                throw new ValueOutOfRangeException(1, Enum.GetNames(typeof(eMenu)).Length, "Value out of range");
            }
            }
        }
示例#18
0
 public void GoToMenu(eMenu i_Menu)
 {
     r_MenuManager.SetCurrentMenu(i_Menu);
     updateMenuDisplay();
 }
示例#19
0
        public static void Menu()
        {
            int x = 0;

            do
            {
                Console.Clear();
                Console.WriteLine(" Enumerable Methods Menu - Immediate Operators\n ");
                Console.WriteLine(" 0.  Website \n ");
                Console.WriteLine(" 1.  MethodToList \n ");
                Console.WriteLine(" 2.  MaxMinMethod \n");
                Console.WriteLine(" 3.  AllMethod \n");
                Console.WriteLine(" 4.  CountMethod \n");
                Console.WriteLine(" 5.  Distinct Method \n");
                Console.WriteLine(" 6.  Except Method \n");
                Console.WriteLine(" 7.  First Method \n");
                Console.WriteLine(" 8.  Intersect Method \n");
                Console.WriteLine(" 9.  Quit            \n\n ");
                Console.Write(" Enter Number to execute Routine ");

                eMenu selection = (eMenu)(Common.readInt("Enter Number to Execute Routine : ", 0, 9));
                switch (selection)
                {
                case eMenu.WebSite:
                    Website();
                    break;

                case eMenu.MethodToList:
                    MethodToList();
                    break;

                case eMenu.MaxMinMethod:
                    MaxMinMethod();
                    break;

                case eMenu.AllMethod:
                    ALLMethod();
                    break;

                case eMenu.CountMethod:
                    CountMethod();
                    break;

                case eMenu.DistinctMethod:
                    DistinctMethod();
                    Console.ReadKey();
                    break;

                case eMenu.ExceptMethod:
                    ExceptMethod();
                    Console.ReadKey();
                    break;

                case eMenu.FirstMethod:
                    FirstMethod();
                    Console.ReadKey();
                    break;

                case eMenu.IntersectMethod:
                    IntersectMethod();
                    Console.ReadKey();
                    break;

                case eMenu.Quit:
                    x = 9;
                    break;

                default: Console.WriteLine(" Invalid Number");
                    break;
                }
            } while (x < 9);
        }  // End Menu
示例#20
0
 private void setMenu(eMenu i_Menu)
 {
     m_PreviousMenu = m_CurrentMenu;
     m_CurrentMenu = i_Menu;
     m_CurrentMenuItems = r_MenusMap[i_Menu].CreateMenuList(r_EventListener);
     m_MenuTitle = r_MenusMap[i_Menu].GetMenuTitle();
     m_SelectedItem = 0;
 }
示例#21
0
 public void SetCurrentMenu(eMenu i_Menu)
 {
     setMenu(i_Menu);
 }