예제 #1
0
        private List <LapTop> getLaptops(List <MobileDevice> md = null)
        {
            List <LapTop> laptops = new List <LapTop>();

            if (md != null)
            {
                for (int i = 0; i < 4 && i < md.Count; i++)
                {
                    laptops.Add(getLaptop(md[i].MD_));
                }
            }
            else
            {
                LapTop laptop;

                var rawSqlCmd = db.Database.Connection.CreateCommand();
                rawSqlCmd.CommandText = @"SELECT CpuName
                                          From LapTop;";

                rawSqlCmd.Connection.Open();

                var reader = rawSqlCmd.ExecuteReader();

                while (reader.Read())
                {
                    laptop         = new LapTop();
                    laptop.CpuName = reader.GetString(0);
                    laptops.Add(laptop);
                }
                rawSqlCmd.Connection.Close();
            }
            return(laptops);
        }
예제 #2
0
        public static LapTop getLapTop(System.Data.Common.DbDataReader reader)
        {
            LapTop laptop = new LapTop();

            laptop.MD_         = reader.GetString(reader.GetOrdinal("MD#"));
            laptop.CDPlayer    = reader.GetString(reader.GetOrdinal("CDPlayer"));
            laptop.Adapter     = reader.GetString(reader.GetOrdinal("Adapter"));
            laptop.Port        = reader.GetString(reader.GetOrdinal("Port"));
            laptop.Webcam      = reader.GetString(reader.GetOrdinal("Webcam"));
            laptop.CpuName     = reader.GetString(reader.GetOrdinal("CpuName"));
            laptop.CPUManuName = reader.GetString(reader.GetOrdinal("CPUManuName"));
            laptop.InPort      = reader.GetString(reader.GetOrdinal("InPort"));

            return(laptop);
        }
예제 #3
0
        private LapTop getLaptop(String MDID)
        {
            LapTop laptop = new LapTop();

            var rawSqlCmd = db.Database.Connection.CreateCommand();

            rawSqlCmd.CommandText = @"SELECT CpuName
                                          From LapTop
                                          WHERE LapTop.MD# = @ID;";

            rawSqlCmd.Parameters.Add(new SqlParameter("@ID", MDID));
            rawSqlCmd.Connection.Open();

            var reader = rawSqlCmd.ExecuteReader();

            reader.Read();
            laptop.CpuName = reader.GetString(0);

            rawSqlCmd.Connection.Close();

            return(laptop);
        }
예제 #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("START RUNNING ADAPTER.");
            Console.WriteLine("To use american socket press 1");
            Console.WriteLine("To use bicicle dinamo press 2");
            Console.WriteLine("To use car battery press 3");
            Console.WriteLine("To use solar battery press 4");
            Console.WriteLine("To use turbine generator press 5");
            Console.WriteLine("To use usb port press 6");

            char adapter = Console.ReadKey().KeyChar;

            switch (adapter)
            {
            case '1':
                Console.WriteLine("App: Launched american socket.");
                AmericanSocket        amerSocket        = new AmericanSocket();
                AmericanSocketAdapter amerSocketAdapter = new AmericanSocketAdapter(amerSocket);
                _ = new LapTop(amerSocketAdapter.OutputVoltage);
                break;

            case '2':
                Console.WriteLine("App: Launched bicicle dinamo.");
                BicicleDinamo  bicicleDinamo        = new BicicleDinamo();
                UsbPortAdapter bicicleDinamoAdapter = new UsbPortAdapter(bicicleDinamo);
                _ = new LapTop(bicicleDinamoAdapter.OutputVoltage);
                break;

            case '3':
                Console.WriteLine("App: Launched car battery.");
                CarBattery        carBattery        = new CarBattery();
                CarBatteryAdapter carBatteryAdapter = new CarBatteryAdapter(carBattery);
                _ = new LapTop(carBatteryAdapter.OutputVoltage);
                break;

            case '4':
                Console.WriteLine("App: Launched solar battery.");
                SolarBattery        solarBattery        = new SolarBattery();
                SolarBatteryAdapter solarBatteryAdapter = new SolarBatteryAdapter(solarBattery);
                _ = new LapTop(solarBatteryAdapter.OutputVoltage);
                break;

            case '5':
                Console.WriteLine("App: Launched turbine generator.");
                TurbineGenerator        turbineGenerator        = new TurbineGenerator();
                TurbineGeneratorAdapter turbineGeneratorAdapter = new TurbineGeneratorAdapter(turbineGenerator);
                _ = new LapTop(turbineGeneratorAdapter.OutputVoltage);
                break;

            case '6':
                Console.WriteLine("App: Launched usb port.");
                UsbPort        usbSource      = new UsbPort();
                UsbPortAdapter usbPortAdapter = new UsbPortAdapter(usbSource);
                _ = new LapTop(usbPortAdapter.OutputVoltage);
                break;

            default:
                Console.WriteLine("Something went wrong. Please try again.");
                Main(new string[0]);
                break;
            }

            Console.WriteLine("END RUNNING ADAPTER.");
            Console.ReadKey();
        }
예제 #5
0
        static void Main(string[] args)
        {
            List <Electronics>       listOfElectronicDevices = new List <Electronics>();
            LinkedList <Electronics> listOfDevicesInNetWork  = new LinkedList <Electronics>();
            LapTop acer = new LapTop("Acer", 500, 8, 2.1);

            listOfElectronicDevices.Add(acer);
            LapTop msi = new LapTop("MSI", 650, 16, 2.9);

            listOfElectronicDevices.Add(msi);
            Console.WriteLine(acer.laptop + " 1:\n" + acer.ToString());
            Console.WriteLine(msi.laptop + " 2:\n" + msi.ToString());

            Server intel = new Server("Intel", 200, 120, 8);

            listOfElectronicDevices.Add(intel);
            Server amd = new Server("AMD", 300, 140, 12);

            listOfElectronicDevices.Add(amd);
            Console.WriteLine(intel.server + " 1:\n" + intel.ToString());
            Console.WriteLine(amd.server + " 2:\n" + amd.ToString());

            PlasmTV samsung = new PlasmTV("Samsung", 300, 32, "1920x1080");

            listOfElectronicDevices.Add(samsung);
            PlasmTV lg = new PlasmTV("LG", 500, 50, "3840x2160");

            listOfElectronicDevices.Add(lg);
            Console.WriteLine(samsung.plazmTV + " 1:\n" + samsung.ToString());
            Console.WriteLine(lg.plazmTV + " 2:\n" + lg.ToString());

            LEDTV sharp = new LEDTV("Sharp", 350, 40, 60);

            listOfElectronicDevices.Add(sharp);
            LEDTV xiaomi = new LEDTV("Xiaomi", 700, 65, 75);

            listOfElectronicDevices.Add(xiaomi);
            Console.WriteLine(sharp.ledTV + " 1:\n" + sharp.ToString());
            Console.WriteLine(xiaomi.ledTV + " 2:\n" + xiaomi.ToString());

            PlayerDevice sony = new PlayerDevice("Sony", 350, "MP3, AVC");

            listOfElectronicDevices.Add(sony);
            PlayerDevice panasonic = new PlayerDevice("Panasonic", 700, "MP3, Flac");

            listOfElectronicDevices.Add(panasonic);
            Console.WriteLine(sony.player + " 1:\n" + sony.ToString());
            Console.WriteLine(panasonic.player + " 2:\n" + panasonic.ToString());

            Console.WriteLine(sony.GetGeneralPower());
            Console.WriteLine(acer.GetGeneralMemory());

            Generator generator = new Generator("Generator", 3000);

            Console.WriteLine(generator.GetAvailablePower());
            Console.WriteLine(generator.GetAvailablePower());

            generator.AllDevicesInNetWork(ref listOfDevicesInNetWork);
            MainProgram(listOfElectronicDevices, ref listOfDevicesInNetWork, generator);

            Console.ReadLine();
        }