Пример #1
0
        static void Main()
        {
            IList <Payment> paymentsA = new List <Payment>()
            {
                new Payment("Utilities", 123.5m),
                new Payment("Groceries", 28.60m),
            };

            IList <Payment> paymentsB = new List <Payment>()
            {
                new Payment("Milk", 1.5m),
                new Payment("Bread", 1.1m),
                new Payment("Organge juice", 2.2m),
            };

            Customer ivan = new Customer("Ivan", "Ivanov", "Ivanov", "8910041276", "Ruse, 'Mladost', st. Vyzrajdane",
                                         "0876112435", "*****@*****.**", paymentsA, CustomerType.Regular);
            Customer george = new Customer("George", "Mikov", "Ivanov", "0010041276", "Sofia, 'Mladost', st. Vyzrajdane",
                                           "0889112090", "*****@*****.**", paymentsB, CustomerType.Diamond);
            Customer ivanClone = (Customer)ivan.Clone();

            Console.WriteLine(ivan.ToString());
            Console.WriteLine(ivan.CompareTo(george));
            Console.WriteLine(ivan == george);
            Console.WriteLine();

            Console.WriteLine(ivanClone.ToString());
            Console.WriteLine(ivanClone.CompareTo(ivan));
            Console.WriteLine(ivanClone == ivan);
        }
Пример #2
0
        static void Main()
        {
            IList<Payment> paymentsA = new List<Payment>()
            {
                new Payment("Utilities", 123.5m),
                new Payment("Groceries", 28.60m),
            };

            IList<Payment> paymentsB = new List<Payment>()
            {
                new Payment("Milk", 1.5m),
                new Payment("Bread", 1.1m),
                new Payment("Organge juice", 2.2m),
            };

            Customer ivan = new Customer("Ivan", "Ivanov", "Ivanov", "8910041276", "Ruse, 'Mladost', st. Vyzrajdane",
                "0876112435", "*****@*****.**", paymentsA, CustomerType.Regular);
            Customer george = new Customer("George", "Mikov", "Ivanov", "0010041276", "Sofia, 'Mladost', st. Vyzrajdane",
                "0889112090", "*****@*****.**", paymentsB, CustomerType.Diamond);
            Customer ivanClone = (Customer)ivan.Clone();

            Console.WriteLine(ivan.ToString());
            Console.WriteLine(ivan.CompareTo(george));
            Console.WriteLine(ivan == george);
            Console.WriteLine();

            Console.WriteLine(ivanClone.ToString());
            Console.WriteLine(ivanClone.CompareTo(ivan));
            Console.WriteLine(ivanClone == ivan);
        }
Пример #3
0
        static void Main()
        {
            CustomerType typeGolden  = CustomerType.Golden;
            CustomerType typeDiamond = CustomerType.Diamond;
            Payment      easyPay     = new Payment("EasyPay", 200);
            Payment      ePay        = new Payment("EPay", 400);

            Customer firstTestCustomer  = new Customer("Ivan", "Ivanov", "Draganov", "200", "Sofia", "0882222", "[email protected]", typeGolden);
            Customer secondTestCustomer = new Customer("Zenit", "Zenitov", "Krokodilov", "400", "Sofia", "555", "[email protected]", typeDiamond);

            firstTestCustomer.AddPayment(easyPay);

            Console.WriteLine(firstTestCustomer.ToString());
            Console.WriteLine(secondTestCustomer.ToString());
            Console.WriteLine(firstTestCustomer.CompareTo(secondTestCustomer));

            Customer copyOfFirst         = firstTestCustomer;
            Customer firstCustomerCloned = (Customer)firstTestCustomer.Clone();

            copyOfFirst.FirstName = "Hi";

            Console.WriteLine(copyOfFirst);
            Console.WriteLine(firstTestCustomer);
            Console.WriteLine(firstCustomerCloned);
        }
Пример #4
0
        static void Main()
        {
            IList<Payment> paymentsA = new List<Payment>()
            {
                new Payment("Utilities", 123.5m),
                new Payment("Groceries", 28.60m),
            };

            IList<Payment> paymentsB = new List<Payment>()
            {
                new Payment("Chocolate", 1.9m),
                new Payment("Coca Cola", 1.3m),
                new Payment("Vodka", 2.9m),
            };

            Customer ivan = new Customer("Simo", "Georgiev", "Vulchev", "8901221233", "Sofia, 'Suha Reka', st. Botio Petkov", 
                "0876441122", "*****@*****.**", paymentsA, CustomerType.Regular);
            Customer george = new Customer("Vasko", "Minchev", "Georgiev", "7712221122", "Dupnica, 'Gorublqne', str. Lipov Rut",
                "0885707488", "*****@*****.**", paymentsB, CustomerType.Diamond);
            Customer ivanClone = (Customer)ivan.Clone();

            Console.WriteLine(ivan.ToString());
            Console.WriteLine(ivan.CompareTo(george));
            Console.WriteLine(ivan == george);
            Console.WriteLine();

            Console.WriteLine(ivanClone.ToString());
            Console.WriteLine(ivanClone.CompareTo(ivan));
            Console.WriteLine(ivanClone == ivan);
        }
Пример #5
0
        static void Main(string[] args)
        {
            Payment        first    = new Payment("Keyboard", 120);
            Payment        second   = new Payment("Mouse", 100);
            Payment        third    = new Payment("Monitor", 670);
            List <Payment> payments = new List <Payment>();

            payments.Add(first);
            payments.Add(second);
            payments.Add(third);
            Customer one  = new Customer("Petar", "Rusev", "Rusev", "8701239089", "Sofia,Diana Bad,ul.Loven Park 3", "0897123852", "*****@*****.**", payments, GetEnumDescription.GetDescription(CustomerType.Diamond, ""));
            Customer four = new Customer("Ivan", "Rusev", "Rusev", "8701230987", "Sofia,Diana Bad,ul.Loven Park 3", "0897123852", "*****@*****.**", payments, GetEnumDescription.GetDescription(CustomerType.Gold, ""));
            Customer two  = (Customer)one.Clone();

            Console.WriteLine(one.ToString());
            Console.WriteLine(two.ToString());
            foreach (Payment p in one.Payments)
            {
                Console.WriteLine(p);
            }
            foreach (Payment p in two.Payments)
            {
                Console.WriteLine(p);
            }
            Console.WriteLine(one.CompareTo(four));
        }
Пример #6
0
        static void Main()
        {
            List <Payment> paymentList1 = new List <Payment>()
            {
                new Payment("Laptop", 3000),
                new Payment("Iphone", 2000)
            };

            List <Payment> paymentList2 = new List <Payment>()
            {
                new Payment("Tablet", 500),
                new Payment("Iphone", 2000),
                new Payment("TV", 4000)
            };


            Customer customer1 = new Customer("Petko", "Peshov", "Petkov", 123456789, "Sofia ul.60", "+359 88 123 4523", "*****@*****.**", paymentList1, CustomerType.Regular);
            Customer customer2 = new Customer("Anna", "Mileva", "Ivanova", 123123123, "Botevgrad ul.10", "+359 88 000 2222", "*****@*****.**", paymentList2, CustomerType.Golden);
            Customer customer3 = new Customer("Anna", "Mileva", "Ivanova", 123123123, "Varna ul.10", "+359 88 000 2222", "*****@*****.**", paymentList2, CustomerType.Diamond);

            Console.WriteLine(customer1.ToString());
            Console.WriteLine("Is equal: ");
            if (Equals(customer3, customer2))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.WriteLine("Clone ");
            Customer cloned = customer1.Clone();

            cloned.FirstName = "Kiro";
            cloned.LastName  = "Kirov";
            cloned.Id        = 36589758;
            Console.WriteLine(cloned.ToString());
            Console.WriteLine(customer1.ToString());
        }
        private static void Main()
        {
            List<Payment> pays = new List<Payment>();
            Payment loan = new Payment("mortgage", 250);
            Payment rent = new Payment("rent", 350);
            pays.Add(loan);
            pays.Add(rent);
            Customer joro = new Customer("Petar", "Ivanov", "Georgiev", 8902021001, "Varna, Gen. Kolev 24", "1232143243", "*****@*****.**", pays, CustomerType.Regular);

            Console.WriteLine(joro);
            Object stamat = joro.Clone();
            joro.FirstName = "Aleksandur";
            Console.WriteLine();
            Console.WriteLine(joro);
            Console.WriteLine(joro.ToString());

            Payment payment = new Payment("Dell", 600);
            Payment payment2 = new Payment("Dell", 600);

            Customer gosho = new Customer("Gosho", "Goshev", "Goshev", 6212123344, "jivee nablizo", "0887 888888", "*****@*****.**", pays, CustomerType.Diamond);
            Customer pesho = new Customer("Gosho", "Goshev", "Goshev", 6212123344, "jivee nablizo", "0887 888888", "*****@*****.**", pays, CustomerType.Diamond);
            Customer peshoPeshev = new Customer("Pesho", "Peshev", "Peshev", 311214244, "jivee nqkyde", "0887 823888", "*****@*****.**", pays, CustomerType.Golden);

            Console.WriteLine("Are gosho and pesho equal: {0}", Equals(gosho, pesho));
            Console.WriteLine("Are pesho and pesho peshev equal: {0}", Equals(pesho, peshoPeshev));
            Console.WriteLine("Are gosho and pesho equal using '==': {0}", (gosho == pesho));
            Console.WriteLine(gosho);
            Console.WriteLine("Pesho Peshev HashCode is: {0}", peshoPeshev.GetHashCode());

            var nasko = (Customer)peshoPeshev.Clone();
            nasko.FirstName = "Nasko";
            nasko.MiddleName = "Atanasov";
            nasko.LastName = "Naskov";
            Console.WriteLine();
            Console.WriteLine("Original after cloning: {0}", peshoPeshev);
            Console.WriteLine();
            Console.WriteLine("Clone: {0}", nasko);

            var atanas = (Customer)nasko.Clone();
            atanas.Id = 411214244;
            Customer[] customers = { gosho, atanas, nasko, peshoPeshev };
            Array.Sort(customers);
            Console.WriteLine();
            Console.WriteLine("Sorted customers(first name, egn):");
            foreach (var customer in customers)
            {
                Console.WriteLine(customer.FirstName + " " + customer.LastName + " " + customer.Id);
            }
        }
Пример #8
0
        static void Main(string[] args)
        {
            Payments paymentPc    = new Payments("PC", 1899);
            Payments paymentOven  = new Payments("Oven", 1111);
            Payments paymentBills = new Payments("Bills", 350);
            var      payments     = new List <Payments>()
            {
                paymentPc, paymentOven, paymentBills
            };

            Customer ivan = new Customer("Ivan",
                                         "Geshov",
                                         "Popov",
                                         8901034546,
                                         "1000 Sofia, str.Vasil Levski 78",
                                         0888223344,
                                         "*****@*****.**",
                                         payments,
                                         customType.Regular);

            Customer pesho = new Customer("Pesho",
                                          "Dobrev",
                                          "Volev",
                                          8309034116,
                                          "Kaspichan, str.Hristo Botev 33",
                                          0888777777,
                                          "*****@*****.**",
                                          payments,
                                          customType.Diamond);

            Customer cloning = ivan.Clone();

            Console.WriteLine("{0}\n", ivan.ToString());

            Console.WriteLine("\tCompare Customer Ivan with his deep clone \n" +
                              "Ivan == cloning : {0}\n", ivan.CompareTo(cloning) == 0 ? "True" : "False");

            Console.WriteLine("{0}\n", pesho.ToString());

            Console.WriteLine("\tCompare Customer Ivan with Pesho \n" +
                              "Ivan == Pesho : {0}\n", ivan.CompareTo(pesho) == 0 ? "True" : "False");
        }
Пример #9
0
        static void Main(string[] args)
        {
            Payments paymentPc = new Payments("PC", 1899);
            Payments paymentOven = new Payments("Oven", 1111);
            Payments paymentBills = new Payments("Bills", 350);
            var payments = new List<Payments>() { paymentPc, paymentOven, paymentBills };

            Customer ivan = new Customer("Ivan",
                "Geshov",
                "Popov",
                8901034546,
                "1000 Sofia, str.Vasil Levski 78",
                0888223344,
                "*****@*****.**",
                payments,
                customType.Regular);

            Customer pesho = new Customer("Pesho",
               "Dobrev",
               "Volev",
               8309034116,
               "Kaspichan, str.Hristo Botev 33",
               0888777777,
               "*****@*****.**",
               payments,
               customType.Diamond);

            Customer cloning = ivan.Clone();

            Console.WriteLine("{0}\n", ivan.ToString());

            Console.WriteLine("\tCompare Customer Ivan with his deep clone \n" +
                "Ivan == cloning : {0}\n", ivan.CompareTo(cloning) == 0 ? "True" : "False");

            Console.WriteLine("{0}\n", pesho.ToString());

            Console.WriteLine("\tCompare Customer Ivan with Pesho \n" +
               "Ivan == Pesho : {0}\n", ivan.CompareTo(pesho) == 0 ? "True" : "False");
        }
Пример #10
0
 static void Main(string[] args)
 {
     Payment first=new Payment("Keyboard",120);
     Payment second=new Payment("Mouse",100);
     Payment third=new Payment("Monitor",670);
     List<Payment>payments=new List<Payment>();
     payments.Add(first);
     payments.Add(second);
     payments.Add(third);
     Customer one = new Customer("Petar", "Rusev", "Rusev", "8701239089", "Sofia,Diana Bad,ul.Loven Park 3", "0897123852", "*****@*****.**",payments,GetEnumDescription.GetDescription(CustomerType.Diamond,""));
     Customer four = new Customer("Ivan", "Rusev", "Rusev", "8701230987", "Sofia,Diana Bad,ul.Loven Park 3", "0897123852", "*****@*****.**", payments, GetEnumDescription.GetDescription(CustomerType.Gold, ""));
     Customer two = (Customer)one.Clone();
     Console.WriteLine(one.ToString());
     Console.WriteLine(two.ToString());
     foreach(Payment p in one.Payments)
     {
         Console.WriteLine(p);
     }
     foreach (Payment p in two.Payments)
     {
         Console.WriteLine(p);
     }
     Console.WriteLine(one.CompareTo(four));
 }