Example #1
0
        void DeliteSpeedHDD()
        {
            Console.Clear();
            Console.Write("Please, enter speed HDD to delite: ");
            int Temp = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < OBJ.Count; i++)
            {
                if (OBJ[i] is HDD)
                {
                    HDD P = OBJ[i] as HDD;
                    if (P.SizeP == Temp)
                    {
                        OBJ.Remove(OBJ[i]);
                        i = 0;
                    }
                }
            }
        }
Example #2
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();
        }
Example #3
0
        void add_hdd()
        {
            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 load: ");
            int SizeP = Convert.ToInt32(Console.ReadLine());

            Console.Write("Enter spead save: ");
            int SpeedHDD = Convert.ToInt32(Console.ReadLine());

            Storage p = new HDD("HDD", ManufacturerName, Model, quantity, Price, SizeP, SpeedHDD);

            OBJ.Add(p);
        }
Example #4
0
        void SerchHDD()
        {
            SerchStart();
            Console.WriteLine("6.SizeP");
            Console.WriteLine("7.SpeedHDD");

            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 HDD)
                    {
                        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 HDD)
                    {
                        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 HDD)
                    {
                        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 HDD)
                    {
                        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 HDD)
                    {
                        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 HDD)
                    {
                        HDD Tem = P as HDD;
                        if (Tem.SizeP == 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 HDD)
                    {
                        HDD Tem = P as HDD;
                        if (Tem.SpeedHDD == number)
                        {
                            Console.WriteLine(i++);
                            P.Print();
                            Console.WriteLine();
                        }
                    }
                }
                break;



            case 8:
                return;
            }
        }
Example #5
0
        void EditHDD(HDD P, int poz)
        {
            int    number = 0;
            string temp   = null;

            do
            {
                try
                {
                    EditStart();
                    Console.WriteLine("5.SizeP");
                    Console.WriteLine("6.SpeedHDD");
                    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.SizeP = number;
                        break;

                    case 6:
                        Console.Write("Please enter value: ");
                        number     = Convert.ToInt32(Console.ReadLine());
                        P.SpeedHDD = 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);
        }