Example #1
0
        static void Main(string[] args)
        {
            string    path      = @"C:\Users\NDM\Downloads\country.csv";
            int       count     = 1;
            CsvReader csvReader = new CsvReader(path);

            Console.Write("Input number row:");
            string inputnumber = Console.ReadLine();
            int    number      = ValidatedData.CheckNumberMaxMinInt(inputnumber);

            foreach (Country item in csvReader.ReadFirstNCountries(10))
            {
                if (count++ % number == 0)
                {
                    Console.Write("Press any key next page");
                    Console.ReadKey();
                }

                if (item != null)
                {
                    Console.WriteLine(item.Name.PadRight(40, ' ') + item.Population);
                }
            }
            Console.ReadKey();
        }
Example #2
0
        public void InsertStudent()
        {
            studentMark = new StudentMark();
            Console.Write("Please input FullName: ");
            studentMark.FullName = Console.ReadLine();
            Console.Write("Please input Class: ");
            studentMark.Class = Console.ReadLine();
            Console.Write("Please input Semester: ");
            string semester = Console.ReadLine();

            studentMark.Semester = ValidatedData.CheckNumberInt(semester);
            Console.Write("Please input marks1 of subject: ");
            string mark1 = Console.ReadLine();

            studentMark[0] = ValidatedData.CheckNumberMaxMinInt(mark1);
            Console.Write("Please input marks2 of subject: ");
            string mark2 = Console.ReadLine();

            studentMark[1] = ValidatedData.CheckNumberMaxMinInt(mark2);
            Console.Write("Please input marks3 of subject: ");
            string mark3 = Console.ReadLine();

            studentMark[2] = ValidatedData.CheckNumberMaxMinInt(mark3);
            Console.Write("Please input marks4 of subject: ");
            string mark4 = Console.ReadLine();

            studentMark[3] = ValidatedData.CheckNumberMaxMinInt(mark4);
            Console.Write("Please input marks5 of subject: ");
            string mark5 = Console.ReadLine();

            studentMark[4] = ValidatedData.CheckNumberMaxMinInt(mark5);
            hashtable.Add(studentMark.ID, studentMark);
        }
Example #3
0
        static void Main(string[] args)
        {
            int        number;
            Random     rnd       = new Random();
            ArrayList  arraylist = new ArrayList();
            List <int> list      = new List <int>();

            do
            {
                Console.WriteLine("                               ____________________________________________________");
                Console.WriteLine("                              |             Please select an option:               |");
                Console.WriteLine("                              |                                                    |");
                Console.WriteLine("                              |             1.Creat ArrayList ...                  |");
                Console.WriteLine("                              |             2.Creat List ...                       |");
                Console.WriteLine("                              |             3.Find value ArrayList ...             |");
                Console.WriteLine("                              |             4.Edit value ArrayList...              |");
                Console.WriteLine("                              |             5.Find value List ...                  |");
                Console.WriteLine("                              |             6.Edit value List...                   |");
                Console.WriteLine("                              |____________________________________________________|");
                Console.Write("                                           Option:");
                string option = Console.ReadLine();
                number = ValidatedData.CheckNumberInt(option);
                switch (number)
                {
                case 1:
                    CreatArryList(rnd, arraylist);
                    break;

                case 2:
                    CreatList(rnd, list);
                    break;

                case 3:
                    FindValueArrayList(arraylist);
                    break;

                case 4:
                    EditValueArrayList(arraylist);

                    break;

                case 5:
                    FindValueList(list);
                    break;

                case 6:
                    EditValueList(list);
                    break;
                }
            } while (number != 7);
        }
Example #4
0
        static void Main(string[] args)
        {
            string        path      = @"C:\Users\NDM\Downloads\country.csv";
            CsvReaderList csvReader = new CsvReaderList(path);

            csvReader.ReadAllCountries();
            Console.WriteLine("Nhap so luong quoc gia:");
            int    chon;
            string inputNumber = Console.ReadLine();
            int    number2     = ValidatedData.CheckNumberInt(inputNumber);
            int    number      = 0;

            do
            {
                Console.Clear();

                int leng = number + number2;
                if (number + number2 < csvReader.ReadAllCountries().Count)
                {
                    for (int i = number; i < number + number2; i++)
                    {
                        Console.WriteLine(csvReader.ReadAllCountries()[i].Name /*.PadRight(40,' ')*/ + "   " + csvReader.ReadAllCountries()[i].Population);
                    }
                }
                else
                {
                    for (int j = csvReader.ReadAllCountries().Count - 1; j > 150; j--)
                    {
                        Console.WriteLine(csvReader.ReadAllCountries()[j].Name /*.PadRight(40,' ')*/ + "   " + csvReader.ReadAllCountries()[j].Population);
                    }
                }

                Console.WriteLine("Chon menu:");
                Console.WriteLine("1. Next page:");
                Console.WriteLine("2. Exit:");
                string inputChon = Console.ReadLine();
                chon = ValidatedData.CheckNumberInt(inputChon);
                switch (chon)
                {
                case 1:
                    number = number + number2;
                    leng   = leng + number2;
                    break;
                }
            }while (chon != 2);


            Console.ReadKey();
        }
Example #5
0
        static void EditValueArrayList(ArrayList arrayList)
        {
            Console.Write("Please input index number have edit in ArrayList: ");
            string input      = Console.ReadLine();
            int    numberedit = ValidatedData.CheckNumberInt(input);

            Console.Write("Please input value have edit in ArrayList: ");
            string input2    = Console.ReadLine();
            int    valueedit = ValidatedData.CheckNumberInt(input2);

            arrayList[numberedit] = valueedit;
            foreach (var item in arrayList)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine(" ");
        }
Example #6
0
        static void Main(string[] args)
        {
            string path = @"C:\Users\NDM\Downloads\country.csv";
            CsvReaderDictionary csvReaderDictionary = new CsvReaderDictionary(path);
            int count = 0;

            foreach (var item in csvReaderDictionary.ReadAllCountries().Values)
            {
                if (count < 5)
                {
                    Console.WriteLine(item.Name.PadRight(30, ' ') + " " + item.Region.PadRight(30, ' ') + " " + item.Code.PadRight(30, ' ') + " " + item.Population);
                    count++;
                }
            }

            int number;

            do
            {
                Console.WriteLine("                               ____________________________________________________");
                Console.WriteLine("                              |             Please select an option:               |");
                Console.WriteLine("                              |                                                    |");
                Console.WriteLine("                              |             1.Insert number of countries display   |");
                Console.WriteLine("                              |             2.Insert number add countries          |");
                Console.WriteLine("                              |             3.Show All                             |");
                Console.WriteLine("                              |____________________________________________________|");
                Console.Write("                                           Option:");
                string option = Console.ReadLine();
                number = ValidatedData.CheckNumberInt(option);
                switch (number)
                {
                case 1:
                    InsertDisplay(csvReaderDictionary);
                    break;

                case 2:
                    break;

                case 3:
                    ShowAll(csvReaderDictionary);
                    break;
                }
            } while (number != 4);
        }
Example #7
0
        public static void InsertDisplay(CsvReaderDictionary csvReaderDictionary)
        {
            int number = 1;

            Console.Write("Input Number of countries:");
            string abc     = Console.ReadLine();
            int    number2 = ValidatedData.CheckNumberInt(abc);

            Console.Clear();
            foreach (var item in csvReaderDictionary.ReadAllCountries().Values)
            {
                if (number % number2 == 0)
                {
                    Console.ReadKey();
                    Console.Clear();
                }
                Console.WriteLine(item.Name.PadRight(30, ' ') + " " + item.Region.PadRight(30, ' ') + " " + item.Code.PadRight(30, ' ') + " " + item.Population);
                number++;
            }
        }
Example #8
0
        static void Main(string[] args)
        {
            int    number;
            Method method = new Method();

            do
            {
                Console.WriteLine("                               ____________________________________________________");
                Console.WriteLine("                              |             Please select an option:               |");
                Console.WriteLine("                              |                                                    |");
                Console.WriteLine("                              |             1.Insert new Student ...               |");
                Console.WriteLine("                              |             2.View list of Student ...             |");
                Console.WriteLine("                              |             3.Average Mark ...                     |");
                Console.WriteLine("                              |             4.Exit                                 |");
                Console.WriteLine("                              |____________________________________________________|");
                Console.Write("                                           Option:");
                string option = Console.ReadLine();
                number = ValidatedData.CheckNumberInt(option);
                switch (number)
                {
                case 1:
                    method.InsertStudent();
                    break;

                case 2:
                    method.Viewlist();
                    break;

                case 3:
                    method.AveCalAll();
                    method.Viewlist();
                    break;

                case 4:
                    break;
                }
            } while (number != 4);
        }
Example #9
0
        static void FindValueList(List <int> list)
        {
            Console.Clear();
            foreach (var item in list)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine("");
            Console.Write("Please input Find number in List: ");
            string input = Console.ReadLine();

            Console.Write("Index:");
            int numberfind = ValidatedData.CheckNumberInt(input);

            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].Equals(numberfind))
                {
                    Console.Write(i + " ");
                }
            }
            Console.WriteLine("");
        }
Example #10
0
        static void EditInfoPokemon()
        {
            int    idconvert;
            string idsearch;

            Console.Write("Enter ID pokemon: ");
            idsearch  = Console.ReadLine();
            idconvert = ValidatedData.CheckNumberInt(idsearch);

            foreach (var item in listpokemon)
            {
                if (item.ID == idconvert)
                {
                    bool   CheckEdit;
                    int    NumberEdit;
                    string StringEdit;
                    do
                    {
                        Console.WriteLine("1. Edit Name: ");
                        Console.WriteLine("2. Edit Height: ");
                        Console.WriteLine("3. Edit Weight: ");
                        Console.WriteLine("4. Edit HP: ");
                        Console.WriteLine("5. Edit Attack: ");
                        Console.WriteLine("6. Edit Defence: ");
                        Console.WriteLine("7. Edit Speed: ");
                        Console.WriteLine("8. comback Menu: ");
                        Console.WriteLine("--------------------------------------------");
                        Console.Write(" Select menu: ");
                        StringEdit = Console.ReadLine();
                        CheckEdit  = int.TryParse(StringEdit, out NumberEdit);
                        switch (NumberEdit)
                        {
                        case 1:
                            Console.Write(" Name new:");
                            string namenew = Console.ReadLine();
                            item.Name = namenew;
                            break;

                        case 2:
                            Console.Write(" Height new:");
                            string Heightnew = Console.ReadLine();
                            item.Height = Heightnew;
                            break;

                        case 3:
                            Console.Write(" Weight new:");
                            string Weightnew = Console.ReadLine();
                            item.Weight = Weightnew;
                            break;

                        case 4:
                            bool   checkHP;
                            int    HPpart;
                            string HP;
                            do
                            {
                                Console.Write(" HP Pokemon new (1-5000): ");
                                HP      = Console.ReadLine();
                                checkHP = int.TryParse(HP, out HPpart);
                            } while (!checkHP || HPpart < 1 || HPpart > 5000);
                            item.HP = HPpart;
                            break;

                        case 5:
                            bool   checkAttack;
                            float  Attackpart;
                            string AT;
                            do
                            {
                                Console.Write(" Attack Pokemon new (1-100): ");
                                AT          = Console.ReadLine();
                                checkAttack = float.TryParse(AT, out Attackpart);
                            } while (!checkAttack || Attackpart < 1 || Attackpart > 100);
                            item.Attack = Attackpart;
                            break;

                        case 6:
                            bool   checkDefence;
                            float  Defencepart;
                            string DF;
                            do
                            {
                                Console.Write(" Defence Pokemon new (1-100): ");
                                DF           = Console.ReadLine();
                                checkDefence = float.TryParse(DF, out Defencepart);
                            } while (!checkDefence || Defencepart < 1 || Defencepart > 100);
                            item.Defence = Defencepart;
                            break;

                        case 7:
                            bool   checkSpeed;
                            float  Speedpart;
                            string SP;
                            do
                            {
                                Console.Write(" Speed Pokemon (1-100): ");
                                SP         = Console.ReadLine();
                                checkSpeed = float.TryParse(SP, out Speedpart);
                            } while (!checkSpeed || Speedpart < 1 || Speedpart > 100);
                            item.Speed = Speedpart;
                            break;
                        }
                    } while (!CheckEdit || NumberEdit != 8);
                }
            }
        }