Esempio n. 1
0
        static void Main()
        {
            Laptop laptop = new Laptop("Lenovo Yoga 2 Pro", 2259.00);
            Console.WriteLine(laptop);

            Console.WriteLine();

            Laptop laptop2 = new Laptop("HP 250 G2",  "Lenovo", "Intel Core i5-4210U (2-core, 1.70 - 2.70 GHz, 3MB cache)", "8 GB", "Intel HD Graphics 4400", "128GB SSD", "13.3\"(33.78 cm) – 3200 x 1800(QHD +), IPS sensor display", "Li-Ion, 4-cells, 2550 mAh", 4.5, 2259.00);
            Console.WriteLine(laptop2);
        }
Esempio n. 2
0
        static void Main()
        {
            Console.OutputEncoding = Encoding.UTF8;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("bg-BG");

            var lenovo = new Laptop("Lenovo", "Thinkpad");
            var asus = new Laptop("Asus", "P52F", "P6100", "Intel GMA 500", 500, "LCD", 2000, new Battery("Li-Ion", 4, 5000), 6,
                800);

            Console.WriteLine(lenovo);
            Console.WriteLine(asus);
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter model of laptop:");
            string model = Console.ReadLine();

            Console.WriteLine("Please enter manufacturer:");
            string manufacturer = Console.ReadLine();

            Console.WriteLine("Please enter type of the processor:");
            string processor = Console.ReadLine();

            Console.WriteLine("Please enter size of RAM:");
            string readRam = Console.ReadLine();

            Console.WriteLine("Please enter graphics card info:");
            string graphicsCard = Console.ReadLine();

            Console.WriteLine("Please enter HDD size:");
            string hdd = Console.ReadLine();

            Console.WriteLine("Please enter screen info:");
            string screen = Console.ReadLine();

            Console.WriteLine("Please enter battery info:");
            string battery = Console.ReadLine();

            Console.WriteLine("Please enter battery life:");
            string readBatteryLife = Console.ReadLine();

            Console.WriteLine("Please enter price of the laptop:");
            string readPrice = Console.ReadLine();

            Console.WriteLine();
            Console.WriteLine(new string('-', 40));

            int ram;

            if (readRam == "")
            {
                ram = 0;
            }
            else if (!int.TryParse(readRam, out ram))
            {
                throw new ArgumentException("Cannot convert RAM data into int!");
            }
            else
            {
                ram = int.Parse(readRam);
            }

            decimal price;

            if (readPrice == "")
            {
                price = 0;
            }
            else if (!decimal.TryParse(readPrice, out price))
            {
                throw new ArgumentException("Cannot convert price into number!");
            }
            else
            {
                price = decimal.Parse(readPrice);
            }

            double batteryLife;

            if (readBatteryLife == "")
            {
                batteryLife = 0;
            }
            else if (!double.TryParse(readBatteryLife, out batteryLife))
            {
                throw new ArgumentException("Cannot convert RAM data into int!");
            }
            else
            {
                batteryLife = double.Parse(readBatteryLife);
            }

            Battery batt = new Battery(battery, batteryLife);
            //Battery lion = new Battery("Li-Ion, 4-cells, 2550 mAh", 4.2f);
            //Battery nicd = new Battery("Ni-Cd", (float)4.5);
            Laptop lpt_first = new Laptop(model, manufacturer, processor, ram, graphicsCard, hdd, screen, batt, price);

            //Laptop lpt_second = new Laptop("Aspire E3-111-C5GL", (decimal)259.49);
            //Laptop lpt_third = new Laptop("Acer some model", (decimal)1567.43, battery: nicd, processor: "3.2 GHz", ram: "16 GB");
            Console.WriteLine(lpt_first.ToString());
        }
Esempio n. 4
0
        static void Main(string[] args)
        {

            Console.WriteLine("Please enter model of laptop:");
            string model = Console.ReadLine();
            Console.WriteLine("Please enter manufacturer:");
            string manufacturer = Console.ReadLine();
            Console.WriteLine("Please enter type of the processor:");
            string processor = Console.ReadLine();
            Console.WriteLine("Please enter size of RAM:");
            string readRam = Console.ReadLine();
            Console.WriteLine("Please enter graphics card info:");
            string graphicsCard = Console.ReadLine();
            Console.WriteLine("Please enter HDD size:");
            string hdd = Console.ReadLine();
            Console.WriteLine("Please enter screen info:");
            string screen = Console.ReadLine();
            Console.WriteLine("Please enter battery info:");
            string battery = Console.ReadLine();
            Console.WriteLine("Please enter battery life:");
            string readBatteryLife = Console.ReadLine();
            Console.WriteLine("Please enter price of the laptop:");
            string readPrice = Console.ReadLine();
            Console.WriteLine();
            Console.WriteLine(new string('-', 40));

            int ram;
            if (readRam == "") 
            {
                ram = 0;
            }
            else if (!int.TryParse(readRam, out ram))
            {
                throw new ArgumentException("Cannot convert RAM data into int!");
            }
            else
            {
                ram = int.Parse(readRam);
            }

            decimal price;
            if (readPrice == "")
            {
                price = 0;
            }
            else if (!decimal.TryParse(readPrice, out price))
            {
                throw new ArgumentException("Cannot convert price into number!");
            }
            else
            {
                price = decimal.Parse(readPrice);
            }

            double batteryLife;
            if (readBatteryLife == "")
            {
                batteryLife = 0;
            }
            else if (!double.TryParse(readBatteryLife, out batteryLife))
            {
                throw new ArgumentException("Cannot convert RAM data into int!");
            }
            else
            {
                batteryLife = double.Parse(readBatteryLife);
            }

            Battery batt = new Battery(battery, batteryLife);
            //Battery lion = new Battery("Li-Ion, 4-cells, 2550 mAh", 4.2f);
            //Battery nicd = new Battery("Ni-Cd", (float)4.5);
            Laptop lpt_first = new Laptop(model, manufacturer, processor, ram, graphicsCard, hdd, screen, batt, price);
            //Laptop lpt_second = new Laptop("Aspire E3-111-C5GL", (decimal)259.49);
            //Laptop lpt_third = new Laptop("Acer some model", (decimal)1567.43, battery: nicd, processor: "3.2 GHz", ram: "16 GB");
            Console.WriteLine(lpt_first.ToString());
        }