示例#1
0
 public void Edit(int number)
 {
     if (number >= 1 && number < OBJ.Count + 1)
     {
         number--;
         if (OBJ[number] is USB)
         {
             USB P = OBJ[number] as USB;
             Console.Clear();
             EditUSB(P, number);
         }
         else if (OBJ[number] is HDD)
         {
             HDD P = OBJ[number] as HDD;
             Console.Clear();
             EditHDD(P, number);
         }
         else if (OBJ[number] is DVD)
         {
             DVD P = OBJ[number] as DVD;
             Console.Clear();
             EditDVD(P, number);
         }
     }
     else
     {
         Console.WriteLine("ERROR value");
     }
 }
示例#2
0
        void DeliteSpeedUSB()
        {
            Console.Clear();
            Console.Write("Please, enter speed USB to delite: ");
            int Temp = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < OBJ.Count; i++)
            {
                if (OBJ[i] is USB)
                {
                    USB P = OBJ[i] as USB;
                    if (P.SizeUSB == Temp)
                    {
                        OBJ.Remove(OBJ[i]);
                        i = 0;
                    }
                }
            }
        }
示例#3
0
        public void Load()
        {
            FileStream   file   = new FileStream("1.txt", FileMode.Open, FileAccess.Read);
            BinaryReader reader = new BinaryReader(file);

            try
            {
                int     size = reader.ReadInt32();
                Storage p;
                for (int i = 0; i < size - 1 && size > 0; i++)
                {
                    string LOAD = reader.ReadString();
                    if (String.Compare(LOAD, "USB") == 0)
                    {
                        p = new USB();
                        p.Load(reader, LOAD);
                        OBJ.Add(p);
                    }
                    else if (String.Compare(LOAD, "DVD") == 0)
                    {
                        p = new DVD();
                        p.Load(reader, LOAD);
                        OBJ.Add(p);
                    }
                    else if (String.Compare(LOAD, "HDD") == 0)
                    {
                        p = new HDD();
                        p.Load(reader, LOAD);
                        OBJ.Add(p);
                    }
                }
            }
            catch
            {
            };


            reader.Close();
            file.Close();
        }
示例#4
0
        void add_usb()
        {
            Console.Write("Enter Name producer: ");
            string ManufacturerName = Console.ReadLine();

            Console.Write("Enter Model: ");
            string Model = Console.ReadLine();

            Console.Write("Enter quantity: ");
            int quantity = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter Price");
            int Price = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter Size USB: ");
            int SizeUSB = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter speed USB: ");
            int SpeedUSB = Convert.ToInt32(Console.ReadLine());

            Storage p = new USB("USB", ManufacturerName, Model, quantity, Price, SizeUSB, SpeedUSB);

            OBJ.list.Add(p);
        }
示例#5
0
        void SerchUSB()
        {
            SerchStart();
            Console.WriteLine("6.SizeUSB");
            Console.WriteLine("7.SpeedUSB");

            Console.WriteLine("8.Exit");
            Console.Write("Please enter value: ");
            int number = Convert.ToInt32(Console.ReadLine());

            Console.Clear();

            string temp = null;
            int    i    = 1;

            switch (number)
            {
            case 1:


                foreach (Storage P in OBJ)
                {
                    if (P is USB)
                    {
                        Console.WriteLine(i++);
                        P.Print();
                        Console.WriteLine();
                    }
                }
                break;

            case 2:
                Console.Write("Please enter value: ");
                temp = Console.ReadLine();
                foreach (Storage P in OBJ)
                {
                    if (P is USB)
                    {
                        if (String.Compare(P.ManufacturerName, temp) == 0)
                        {
                            Console.WriteLine(i++);
                            P.Print();
                            Console.WriteLine();
                        }
                    }
                }
                break;

            case 3:
                Console.Write("Please enter value: ");
                temp = Console.ReadLine();
                foreach (Storage P in OBJ)
                {
                    if (P is USB)
                    {
                        if (String.Compare(P.Model, temp) == 0)
                        {
                            Console.WriteLine(i++);
                            P.Print();
                            Console.WriteLine();
                        }
                    }
                }
                break;

            case 4:
                Console.Write("Please enter value: ");
                number = Convert.ToInt32(Console.ReadLine());
                foreach (Storage P in OBJ)
                {
                    if (P is USB)
                    {
                        if (P.Size == number)
                        {
                            Console.WriteLine(i++);
                            P.Print();
                            Console.WriteLine();
                        }
                    }
                }
                break;

            case 5:
                Console.Write("Please enter value: ");
                number = Convert.ToInt32(Console.ReadLine());
                foreach (Storage P in OBJ)
                {
                    if (P is USB)
                    {
                        if (P.Price == number)
                        {
                            Console.WriteLine(i++);
                            P.Print();
                            Console.WriteLine();
                        }
                    }
                }
                break;

            case 6:
                Console.Write("Please enter value: ");
                number = Convert.ToInt32(Console.ReadLine());
                foreach (Storage P in OBJ)
                {
                    if (P is USB)
                    {
                        USB Tem = P as USB;
                        if (Tem.SizeUSB == number)
                        {
                            Console.WriteLine(i++);
                            P.Print();
                            Console.WriteLine();
                        }
                    }
                }
                break;

            case 7:
                Console.Write("Please enter value: ");
                number = Convert.ToInt32(Console.ReadLine());
                foreach (Storage P in OBJ)
                {
                    if (P is USB)
                    {
                        USB Tem = P as USB;
                        if (Tem.SpeedUSB == number)
                        {
                            Console.WriteLine(i++);
                            P.Print();
                            Console.WriteLine();
                        }
                    }
                }
                break;



            case 8:
                return;
            }
        }
示例#6
0
        void EditUSB(USB P, int poz)
        {
            int    number = 0;
            string temp   = null;

            do
            {
                try {
                    EditStart();
                    Console.WriteLine("5.SizeUSB");
                    Console.WriteLine("6.SpeedUSB");
                    Console.WriteLine("7.EXIT");
                    number = Convert.ToInt32(Console.ReadLine());
                    switch (number)
                    {
                    case 1:
                        Console.Write("Please enter value: ");
                        temp = Console.ReadLine();
                        P.ManufacturerName = temp;
                        break;

                    case 2:
                        Console.Write("Please enter value: ");
                        temp    = Console.ReadLine();
                        P.Model = temp;
                        break;

                    case 3:
                        Console.Write("Please enter value: ");
                        number = Convert.ToInt32(Console.ReadLine());
                        P.Size = number;
                        break;

                    case 4:
                        Console.Write("Please enter value: ");
                        number = Convert.ToInt32(Console.ReadLine());
                        P.Size = number;
                        break;

                    case 5:
                        Console.Write("Please enter value: ");
                        number    = Convert.ToInt32(Console.ReadLine());
                        P.SizeUSB = number;
                        break;

                    case 6:
                        Console.Write("Please enter value: ");
                        number     = Convert.ToInt32(Console.ReadLine());
                        P.SpeedUSB = number;
                        break;

                    case 7:
                        do
                        {
                            Console.WriteLine("Save edits?\nY/N");
                            temp = Console.ReadLine();
                            switch (temp)
                            {
                            case "Y":
                            case "y":
                                OBJ[poz] = P;
                                return;

                            case "N":
                            case "n":

                                return;

                            default:
                                Console.Clear();
                                Console.WriteLine("This value incorect.");
                                break;
                            }
                        } while (true);
                    }
                    Console.Clear();
                }
                catch (Exception ex) { Console.Clear(); Console.WriteLine(ex); }
            } while (true);
        }