public static void Main()
        {
            Payment payment = new Payment("Dell", 600);
            Payment payment2 = new Payment("Dell", 600);

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

            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.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.EGN = 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.EGN);
            }
        }
        static void Main()
        {
            Payment p1 = new Payment("Coffee", 2.53m);
            Payment p2 = new Payment("Tea", 1.41m);
            Payment p3 = new Payment("Beer", 3.78m);
            Payment p4 = new Payment("Cheese", 6.33m);
            Payment p5 = new Payment("Bread", 1.02m);

            IList<Payment> payments1 = new List<Payment> {p1, p2};
            IList<Payment> payments2 = new List<Payment> { p1, p2 };
            IList<Payment> payments3 = new List<Payment> { p2, p3, p4, p5 };
            IList<Payment> payments4 = new List<Payment> { p3, p4 };
            IList<Payment> payments5 = new List<Payment> { p4, p5 };

            Customer pesho = new Customer("Petar", "Dimitrov", "Petrov", 6005121315, "Sofia", "0888-888888",
                "pesho.abv.bg", payments1, CustomerType.Diamond);
            Customer gosho1 = new Customer("Georgi", "Mihajlov", "Georgiev", 7510124567, "Plovdiv", "0777-777777",
                "gosho.abv.bg", payments3, CustomerType.Golden);
            Customer gosho2 = new Customer("Georgi", "Mihajlov", "Georgiev", 7510124567, "Plovdiv", "0777-777777",
                "gosho.abv.bg", payments3, CustomerType.Golden);
            Customer gosho3 = new Customer("Georgi", "Mihajlov", "Georgiev", 6510124567, "Plovdiv", "0777-777777",
                "gosho.abv.bg", payments3, CustomerType.Golden);
            Customer misho = new Customer("Mihail", "Todorov", "Todorov", 5512024567, "Ruse", "0666-666666",
                "email.abv.bg", payments4, CustomerType.OneTime);

            IList<Customer> customers = new List<Customer>
            {
                pesho, gosho1, gosho2, gosho3, misho
            };

            Console.WriteLine("Print HashCodes:");
            foreach (var customer in customers)
            {
                Console.WriteLine(customer.GetHashCode());
            }
            Console.WriteLine();

            Console.WriteLine("Print equalities: ");
            Console.WriteLine(pesho.Equals(gosho1));
            Console.WriteLine(pesho == gosho1);
            Console.WriteLine(gosho1 == gosho2);
            Console.WriteLine(gosho1 != gosho3);
            Console.WriteLine();

            Console.WriteLine("Prnt cloning:");
            Customer cloning = (Customer)pesho.Clone();
            Console.WriteLine("cloning == pesho? {0}", cloning == pesho);
            Console.WriteLine("Cloning:\n" + cloning);
            Console.WriteLine("Pesho:\n" + pesho);
            cloning.FirstName = "Joro";
            Console.WriteLine("Cloning after changing first name:\n" + cloning);
            Console.WriteLine("Pesho:\n" + pesho);

            Console.WriteLine("Compare to:");
            Console.WriteLine("gosho1 compareTo gosho2: {0}", gosho1.CompareTo(gosho2));
            Console.WriteLine("gosho1 compareTo gosho3: {0}", gosho1.CompareTo(gosho3));
            Console.WriteLine("gosho3 compareTo gosho1: {0}", gosho3.CompareTo(gosho1));
        }
        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);
            }
        }
Exemple #4
0
        static void Main()
        {
            Payment payment = new Payment("Samsung", 1000);
            Payment payment2 = new Payment("Samsung", 1000);

            Customer walter = new Customer("Walter", "Hartwell", "White", 6303210844, "Sofia", "0888 888 888", "*****@*****.**", CustomerType.Diamond, payment);
            Customer philip = new Customer("Philip", "Rodriguez", "Lopez", 9403210844, "Sofia", "0888 888 888", "*****@*****.**", CustomerType.Diamond, payment2);

            Console.WriteLine(Equals(walter, philip));
            Console.WriteLine(walter == philip);
            Console.WriteLine(walter);

            var walterClone = (Customer)walter.Clone();
            Console.WriteLine(walterClone);
        }
 static void Main()
 {
     Payment pay = new Payment("Beer", 0.5M);
     Customer customer = new Customer("Patar", "Ivanov", 1000000000, pay, CustomerType.OneTime);
     Console.WriteLine(customer);
     Console.WriteLine();
     Customer clone = (Customer)customer.Clone();
     clone.AddPayment(new Payment("Rakia", 8M));
     Console.WriteLine(clone);
     Console.WriteLine();
     Console.WriteLine(customer);
     Console.WriteLine();
     Console.WriteLine(customer.GetHashCode());
     Console.WriteLine(clone.GetHashCode());
 }
Exemple #6
0
        static void Main()
        {
            var paymentKocev = new Payment("LG G3", 1200);
            var kocev = new DiamondCustomer("Milen", "Rusev", "Kocev", "38394A", "Varna, Bulgaria", "+359 899 123001", "*****@*****.**", CustomerType.Diamond);
            kocev.Payments.Add(paymentKocev);

            var paymentStoyanov = new Payment("Football Gloves Adidas", 300);
            var stoyanov = new GoldenCustomer("Vladislav", "Boykov", "Stoyanov", "820129ZX", "Razgrad, Bulgaria",
                "+359 2 392910", "*****@*****.**", CustomerType.Golden, paymentStoyanov);
            var stoyanov2 = new GoldenCustomer("Vladislav", "Boykov", "Stoyanov", "820129ZX", "Razgrad, Bulgaria",
                "+359 2 392910", "*****@*****.**", CustomerType.Golden, paymentStoyanov);
            

            Console.WriteLine(kocev);
            Console.WriteLine(stoyanov);

            var isCustomerEqual = stoyanov2.Equals(stoyanov);
            Console.WriteLine(isCustomerEqual);

            Console.WriteLine(stoyanov.GetHashCode() + "\n" + stoyanov2.GetHashCode());
            Console.WriteLine(kocev.GetHashCode() + "\n" + stoyanov.GetHashCode());

            if (stoyanov == kocev)
            {
                Console.WriteLine("The objects are equal");
            }

            if (stoyanov != kocev)
            {
                Console.WriteLine("The objects are not equal");
            }

            Console.WriteLine();
            var clonedCustomer = (Customer)kocev.Clone();
            Console.WriteLine(clonedCustomer);

            Console.WriteLine("Testing CompareTo:");

            if (kocev.CompareTo(clonedCustomer) == 0)
            {
                Console.WriteLine("The two objects are equal.");
            }
        }
Exemple #7
0
        static void Main()
        {
            Payment videoCard = new Payment("Nvidia GTX 670", 250m);
            Payment ssd = new Payment("SSD", 150.32m);
            Customer pesho = new Customer("Pesho", "Ivanov", 8712013812, CustomerType.OneTime, videoCard, ssd);

            Payment vacation = new Payment("Vacation", 1250);
            Customer mariika = new Customer("Mariika", "Petrova", "Ilieva", 3203631101, CustomerType.Diamond, "Plovdiv", null, null, vacation);

            Customer mariikaCopy = (Customer)mariika.Clone();

            Customer goshko = new Customer("Goshko", "Petrov", 9912121212, CustomerType.Golden, ssd, vacation, videoCard);

            Console.WriteLine(pesho == mariika);
            Console.WriteLine(mariika == mariikaCopy);
            Console.WriteLine();

            Customer[] customers = { pesho, mariika, goshko };
            Array.Sort(customers);
            Console.WriteLine(string.Join("\n", customers.ToList()));
        }
Exemple #8
0
        public static void Main()
        {
            var payFollow = new Payment("Desyatka", 10);

            var lusi = new Customer(
                "Lusi",
                "Sharapova",
                9502128796,
                088815500,
                "*****@*****.**",
                CustomerType.OneTime,
                payFollow);

            var doncho = lusi.Clone() as Customer;
            doncho.FirstName = "Doncho";
            doncho.LastName = "Petrov";

            Console.WriteLine(doncho);
            Console.WriteLine(lusi);

            var teodosi = new Customer(
                "teodosi",
                "Tyrnovski",
                85998838,
                0899339949,
                "*****@*****.**",
                CustomerType.Diamond);

            var toncho = teodosi.Clone() as Customer;
            toncho.Id = 8234353535;
            toncho.LastName = "Karamazov";

            var customers = new List<Customer> { lusi, doncho, teodosi, toncho };
            customers.Sort();

            Console.WriteLine(string.Join(", ", customers));
        }
Exemple #9
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));
 }
Exemple #10
0
        static void Main()
        {
            Payment payment = new Payment("laptop", 600);
            Payment payment2 = new Payment("pc", 2300);

            Customer gosho = new Customer("Gosho", "Goshev", "Goshev", 6212123344, "test address 0", "0123456789", "*****@*****.**", Type.Diamond, payment);
            Customer pesho = new Customer("Pesho", "Peshev", "Peshev", 1567515677, "test address 1", "0897654321", "*****@*****.**", Type.Golden, payment);
            Customer tosho = new Customer("Tosho", "Toshev", "Toshev", 4687515615, "test address 23", "0456789123", "*****@*****.**", Type.OneTime);

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

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

            var atanas = (Customer)nasko.Clone();
            atanas.EGN = 411214784;
            Customer[] customers = { gosho, atanas, nasko, pesho };
            Array.Sort(customers);
            Console.WriteLine();
            Console.WriteLine("Sorted customers(first name, egn):");

            foreach (var customer in customers)
            {
                Console.WriteLine(customer.FirstName + " " + customer.LastName + " " + customer.EGN);
            }
        }
        static void Main()
        {
            Payment keyboard = new Payment("Keyboard MODECOM", 35m);
            Payment monitor = new Payment("Monitor Sony", 149.99m);
            Payment glasses = new Payment("Glasses Alpina", 79.80m);
            Payment shoes = new Payment("Sport shoes Adidas", 179.99m);
            Payment dog = new Payment("Husky", 90m);

            Customer gosho = new Customer(
                "Georgi",
                "Petrov",
                "Ivanov",
                "9305054476",
                "Borisova 34",
                "0883-43-43-12",
                "*****@*****.**",
                new List<Payment>() { keyboard, monitor },
                CustomerType.Regular);

            Customer dancho = new Customer(
                "Yordan",
                "Yordanov",
                "Kirov",
                "7305041495",
                "Borisova 55",
                "0883-44-66-92",
                "*****@*****.**",
                new List<Payment>() { glasses, shoes },
                CustomerType.Golden);

            Customer tanq = new Customer(
                "Tatqna",
                "Georgieva",
                "Petrova",
                "7402031596",
                "Borisova 35",
                "0889-49-23-67",
                "*****@*****.**",
                new List<Payment>() { glasses, shoes, dog, monitor },
                CustomerType.Diamond);

            // correct copy
            Customer goshoCopy = (Customer)gosho.Clone();
            goshoCopy.FirstName = "Gecata";
            goshoCopy.Payments.Add(new Payment("Car audi A4", 5000m));
            Console.WriteLine(gosho);
            Console.WriteLine(goshoCopy);
            Console.WriteLine("goshoCopy == gosho : {0}", goshoCopy == gosho);
            Console.WriteLine("gosho.Equals(goshoCopy) : {0}", gosho.Equals(goshoCopy));
            Console.WriteLine("Object.ReferenceEquals(gosho, goshoCopy) : {0}", Object.ReferenceEquals(gosho, goshoCopy));
            Console.WriteLine("\n\n\n");

            // incorrect copy
            goshoCopy = gosho;
            gosho.FirstName = "Goshkata";
            goshoCopy.Payments.Add(new Payment("Car audi A4", 5000m));
            Console.WriteLine(gosho);
            Console.WriteLine(goshoCopy);
            Console.WriteLine("goshoCopy == gosho : {0}", goshoCopy == gosho);
            Console.WriteLine("gosho.Equals(goshoCopy) : {0}", gosho.Equals(goshoCopy));
            Console.WriteLine("Object.ReferenceEquals(gosho, goshoCopy) : {0}", Object.ReferenceEquals(gosho, goshoCopy));
        }