Example #1
0
        public void QLCO(int a)
        {
            int flag = 1;

            while (flag == 1)
            {
                Console.WriteLine("\t\t\t\tDAY LA TANG: " + a);
                Console.WriteLine("\t\t\t\t*****************************MENU*****************************");
                Console.WriteLine("\t\t\t\t***           1. Xuat DS CO                                ***");
                Console.WriteLine("\t\t\t\t***           2. Thao tac voi CO                           ***");
                Console.WriteLine("\t\t\t\t***           3. Xoa CO                                    ***");
                Console.WriteLine("\t\t\t\t***           4. Gop 2 CO                                  ***");
                Console.WriteLine("\t\t\t\t***           5. Thoat                                     ***");
                Console.WriteLine("\t\t\t\t**************************************************************");
                Console.Write("Moi nhap lua chon cua ban => Your choice: ");
                int choice = int.Parse(Console.ReadLine());
                switch (choice)
                {
                case 1:
                {
                    foreach (var item in this.lCo)
                    {
                        item.Xuat();
                    }
                    break;
                }

                case 2:
                {
                    Console.WriteLine("Ban muon thao tac Co thu may: ");
                    int x = int.Parse(Console.ReadLine());
                    this.MenuTemp(x);
                    break;
                }

                case 3:
                {
                    Console.WriteLine("Ban muon xoa Co nao");
                    int x = int.Parse(Console.ReadLine());
                    this.lCo.RemoveAt(x);
                    break;
                }

                case 4:
                {
                    Console.WriteLine("Ban muon gop C0_1 nao vao CO_2 nao: ");
                    Console.Write("Moi nhap thu tu C0 thu nhat: "); int stt1 = int.Parse(Console.ReadLine());
                    Console.Write("Moi nhap thu tu CO thu hai: "); int  stt2 = int.Parse(Console.ReadLine());
                    var           result = this.lCo[stt1].lShape.Union(this.lCo[stt2].lShape);
                    ComplexObject temp   = new ComplexObject(this.lCo[stt2].iFloor);
                    int           mau    = this.lCo[stt2].Color;
                    this.lCo.RemoveAt(stt2); this.lCo.RemoveAt(stt1);
                    foreach (var item in result)
                    {
                        temp.lShape.Add(item);
                    }
                    this.lCo.Add(temp);
                    // Console.WriteLine(this.lCo.Count);
                    this.lCo[this.lCo.Count - 1].Color = mau;
                    this.lCo[this.lCo.Count - 1].SetDiem();
                    break;
                }

                case 5:
                {
                    flag = 0;
                    Console.Clear();
                    break;
                }

                default:
                {
                    Console.Clear();
                    Console.WriteLine("Ban Nhap Sai!!! Vui long nhap lai ~~ ");
                    break;
                }
                }
            }
        }
Example #2
0
        public override void Menu()
        {
            int flag = 1;

            if (this.ListShape.Count == 0)
            {
                this.Nhap();
            }
            try
            {
                if (this.ListShape.Count != 0)
                {
                    while (flag == 1)
                    {
                        int floor = this.iFloor + 1;
                        Console.WriteLine("\t\t\t\tDAY LA TANG: " + floor);
                        Console.WriteLine("\t\t\t\t*****************************MENU*****************************");
                        Console.WriteLine("\t\t\t\t***           1. Thao tac tren hinh Group/UnGroup          ***");
                        Console.WriteLine("\t\t\t\t***           2. Ve Complex Object                         ***");
                        Console.WriteLine("\t\t\t\t***           3. Dien Tich Complex Object                  ***");
                        Console.WriteLine("\t\t\t\t***           4. Chu Vi Complex Object                     ***");
                        Console.WriteLine("\t\t\t\t***           5. Move                                      ***");
                        Console.WriteLine("\t\t\t\t***           6. Phong to                                  ***");
                        Console.WriteLine("\t\t\t\t***           7. thu nho                                   ***");
                        Console.WriteLine("\t\t\t\t***           8. doi mau                                   ***");
                        Console.WriteLine("\t\t\t\t***           9. Xuat thong tin CO                         ***");
                        Console.WriteLine("\t\t\t\t***          10. Quan Ly Danh sach CO                      ***");
                        Console.WriteLine("\t\t\t\t***          11. Thoat                                     ***");
                        Console.WriteLine("\t\t\t\t**************************************************************");
                        Console.Write("Moi nhap lua chon cua ban => Your choice: ");
                        int choice = int.Parse(Console.ReadLine());
                        switch (choice)
                        {
                        case 1:
                        {
                            int x = this.lCo.Count;
                            //x++;
                            ComplexObject Temp = new ComplexObject(this.iFloor + 1);
                            this.lCo.Add(Temp);
                            this.Xuat();
                            Console.WriteLine("Tong so Hinh o tren la: " + this.ListShape.Count);
                            this.lCo[x] = uGroup.Merge(this.ListShape, this.iFloor + 1);
                            Console.Write("Nhap mau cua complex da merge: ");
                            this.lCo[x].Color = int.Parse(Console.ReadLine());
                            this.MenuTemp(x);
                            break;
                        }

                        case 2:
                        {
                            this.Ve();
                            break;
                        }

                        case 3:
                        {
                            Console.WriteLine("Dien Tich Complex Object la: " + this.DienTich());
                            break;
                        }

                        case 4:
                        {
                            Console.WriteLine("Chu Vi Complex Object la: " + this.ChuVi());
                            break;
                        }

                        case 5:
                        {
                            this.Move();
                            Console.WriteLine("Da di chuyen");
                            break;
                        }

                        case 6:
                        {
                            this.PhongTo();
                            Console.WriteLine("Da phong to");
                            break;
                        }

                        case 7:
                        {
                            this.ThuNho();
                            Console.WriteLine("Da thu nho");
                            break;
                        }

                        case 8:
                        {
                            this.changeColor();
                            Console.WriteLine("Da doi mau");
                            break;
                        }

                        case 9:
                        {
                            Console.WriteLine("BAN DANG O TANG THU: " + this.iFloor);
                            this.Xuat();
                            break;
                        }

                        case 10:
                        {
                            this.QLCO(this.iFloor + 1);
                            break;
                        }

                        case 11:
                        {
                            flag = 0;
                            Console.Clear();
                            break;
                        }

                        default:
                        {
                            Console.Clear();
                            Console.WriteLine("Ban Nhap Sai!!! Vui long nhap lai ~~ ");
                            break;
                        }
                        }
                    }
                }
                else
                {
                    throw new Exception("Khong Ton Tai Danh Sach Hinh!!");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Example #3
0
        public void MenuTemp(int x)
        {
            int florida = this.lCo[x].iFloor;
            int flag    = 1;

            try
            {
                if (this.lCo[x].lShape.Count != 0)
                {
                    this.lCo[x].SetDiem();
                    Console.WriteLine("Cac hinh cua CO: " + this.lCo[x].lShape.Count);
                    while (flag == 1)
                    {
                        Console.WriteLine("\t\t\t\tDAY LA TANG: " + florida);
                        Console.WriteLine("\t\t\t\t*****************************MENU*****************************");
                        Console.WriteLine("\t\t\t\t***           1. Add                                       ***");
                        Console.WriteLine("\t\t\t\t***           2. Divide                                    ***");
                        Console.WriteLine("\t\t\t\t***           3. Xuat thong tin                            ***");
                        Console.WriteLine("\t\t\t\t***           4. Thao tac khac                             ***");
                        Console.WriteLine("\t\t\t\t***           5. Ve                                        ***");
                        Console.WriteLine("\t\t\t\t***           6. Thoat ra                                  ***");
                        Console.WriteLine("\t\t\t\t**************************************************************");
                        Console.Write("Moi nhap lua chon cua ban => Your choice: ");
                        int choice = int.Parse(Console.ReadLine());
                        switch (choice)
                        {
                        case 1:
                        {
                            this.Xuat();
                            Console.WriteLine("Ban muon them hinh thu may");
                            int key = int.Parse(Console.ReadLine());
                            this.lCo[x].add(this.lShape[key]);
                            Console.WriteLine("Tong so Hinh o tren la: " + this.lCo[x].ListShape.Count);
                            this.lCo[x].SetDiem();
                            break;
                        }

                        case 2:
                        {
                            ComplexObject temp = this.lCo[x];
                            uGroup.Divided(ref temp);
                            this.lCo[x] = temp;
                            this.lCo[x].SetDiem();
                            Console.WriteLine("Da unGroup");
                            break;
                        }

                        case 3:
                        {
                            //Console.WriteLine(this.iFloor);
                            //Console.WriteLine(Temp.iFloor);
                            Console.WriteLine("BAN DANG O TANG THU: " + florida);
                            this.lCo[x].Xuat();
                            break;
                        }

                        case 4:
                        {
                            this.lCo[x].Menu();
                            break;
                        }

                        case 5:
                        {
                            this.lCo[x].Ve();
                            break;
                        }

                        case 6:
                        {
                            flag = 0;
                            Console.Clear();
                            break;
                        }

                        default:
                        {
                            Console.Clear();
                            Console.WriteLine("Ban Nhap Sai!!! Vui long nhap lai ~~ ");
                            break;
                            // Console.Clear();
                        }
                        }
                    }
                }
                else
                {
                    throw new Exception("Khong Ton Tai Danh Sach Hinh!!");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }