Пример #1
0
        public int indexOf(SV sv)
        {
            int count = 0;

            foreach (SV s in listSV)
            {
                if (sv.MSSV == s.MSSV && sv.Name == s.Name && sv.Age == s.Age)
                {
                    return(count);
                }
                count++;
            }

            return(0);
        }
Пример #2
0
        public void update(SV sv, int index)
        {
            int count = 0;

            foreach (SV s in listSV)
            {
                if (index == count)
                {
                    s.MSSV = sv.MSSV;
                    s.Name = sv.Name;
                    s.Age  = sv.Age;
                    break;
                }
                count++;
            }
        }
Пример #3
0
        public void add(SV sv)
        {
            this.lenght++;
            if (this.listSV == null)
            {
                listSV    = new SV[lenght];
                listSV[0] = sv;
            }
            else
            {
                SV[] temp = this.listSV;
                listSV = new SV[lenght];
                for (int i = 0; i < temp.Length; i++)
                {
                    this.listSV[i] = temp[i];
                }

                listSV[this.lenght - 1] = sv;
            }
        }
Пример #4
0
        public void createDB()
        {
            SV s1 = new SV {
                MSSV = "1", Name = "khanh", Age = 19
            };
            SV s2 = new SV {
                MSSV = "1", Name = "hung", Age = 14
            };
            SV s3 = new SV {
                MSSV = "1", Name = "manh", Age = 20
            };
            SV s4 = new SV {
                MSSV = "1", Name = "duy", Age = 17
            };

            add(s1);
            add(s2);
            add(s3);
            add(s4);
        }
Пример #5
0
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");

            //string s = "123";
            // int y = Int32.Parse(s);
            //Console.WriteLine(y + 1);
            // int y;
            //Int32.TryParse(s, out y);
            //Console.WriteLine(y + 1);
            //int z = Convert.ToInt32(s);
            //Console.WriteLine(z +1);

            // int x = 1, y =2;
            // Console.WriteLine("{0} + {1} = {2}", x,y,x+y);

            // string[] arr = new string[4];

            // foreach(string i in arr){
            //     Console.WriteLine(i);
            // }

            // string[][] arr2 = new string[3][];
            // arr2[0] = new string [] {"A", "C"};
            // arr2[1] = new string[] {"B", "D"};
            // arr2[2] = new string[] {"F", "E", "V", "T"};

            // foreach (string[] str in arr2){
            //     foreach(string i in str){
            //         Console.WriteLine(i);
            //     }
            // }

            QLSV qLSV = new QLSV();

            qLSV.createDB();
            qLSV.show();
            // Console.WriteLine("================");
            //   qLSV.sort();
            //   qLSV.show();


            SV s1 = new SV {
                MSSV = "112", Name = "asd123213", Age = 192
            };

            Console.WriteLine(qLSV.indexOf(s1));

            qLSV.update(s1, 3);
            qLSV.show();
            Console.WriteLine("================");
            // qLSV.removeAt(3);
            //qLSV.show();

            SV s2 = new SV {
                MSSV = "1", Name = "hung", Age = 14
            };

            Console.WriteLine("================");
            Console.WriteLine(qLSV.indexOf(s2));
            Console.WriteLine("================");
            qLSV.remove(s1);
            qLSV.show();
        }
Пример #6
0
        public void remove(SV sv)
        {
            int index = indexOf(sv);

            removeAt(index);
        }