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);
            }
        }
Example #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);
        }
Example #3
0
        public Account.Account addAccount(ref Customer.Customer c)
        {
            Account.Account a = new Account.Account();

            if (!validateCustomer(c))
            {
                addCustomer(ref c);
            }

            int acc_id = generateRandomID();

            Console.WriteLine("Enter Balance to be deposited: ");
            int bal = Convert.ToInt32(Console.ReadLine());

            Console.Write("Select Account-type:\n* Deposit\n* Loan\n* Mortgage\n: ");
            string type = Console.ReadLine();

            a.account_id       = acc_id;
            a.customer_balance = bal;
            a.account_type     = type;
            a.interst_rate     = CalculateInterest(c.cust_type, ref a);


            return(a);
        }
Example #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);
        }
Example #5
0
 static void Main(string[] args)
 {
     Customer customer = new Customer(9502030405, "hasan", "hasan", "hasan", "0884899549", "*****@*****.**", "sadasd",
         CustomerType.Diamond, new List<Payment>());
     
     var newCustomer = customer.Clone();
     Console.WriteLine(customer);
 }
Example #6
0
 static unsafe void Main(string[] args)
 {
     var cust = new Customer("Aleksandar", "Nikolaev", "Nikolave", 9305123509, "Sofia", 089999999,
         "*****@*****.**", CustomerType.Diamond, new Payment("Bugatti", 1000000));
     var cloned = (Customer)cust.Clone();
     Console.WriteLine(cust == cloned);
     Console.WriteLine(object.ReferenceEquals(cust, cloned));
 }
Example #7
0
        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));
        }
Example #8
0
 private bool validateCustomer(Customer.Customer customer)
 {
     if (customer.cust_id == -1)
     {
         //Console.WriteLine("Invalid customer");
         return(false);
     }
     return(true);
 }
Example #9
0
        private void addCustomer(ref Customer.Customer c)
        {
            Console.WriteLine("Enter your name: ");
            string name = Console.ReadLine();

            int id = generateRandomID();

            Console.WriteLine("Are you Individual/Company?: ");
            string type = Console.ReadLine();

            c.cust_id   = id;
            c.cust_name = name;
            c.cust_type = type;
        }
Example #10
0
        static void Main(string[] args)
        {
            var customer = new Customer("Mariq", "Gogova","Totova", "11121314",
                "Sofia 34", "12321", "*****@*****.**", new List<Payment>() { new Payment("abv", 11212) },CustomerType.Golden);

            var copy = (Customer)customer.Clone();

            Console.WriteLine(customer == copy);
            Console.WriteLine(customer);
            copy.LastName = "Changes!";

            Console.WriteLine(customer);
            Console.WriteLine(copy);
        }
Example #11
0
        public static void Main()
        {
            Customer pesho = new Customer(
                1234567890,
                "Petar",
                "Ivanov",
                "Petrov",
                "0884565250",
                "*****@*****.**",
                CustomerType.Diamond,
                new List<Payment>() { new Payment("Cosmo disk", 124.29m) });

            Customer misho = new Customer(
                1023456789,
                "Mihail",
                "Ivanov",
                "Mihailov",
                "0884565253",
                "*****@*****.**",
                CustomerType.Golden,
                new List<Payment>() { new Payment("Cosmo disk", 124.29m), new Payment("magnitni nakolenki", 45.68m) });

            Customer gosho = new Customer(
                1203456789,
                "Georgi",
                "Borisov",
                "Georgiev",
                "0884565252",
                "*****@*****.**",
                CustomerType.Regular,
                new List<Payment>() { new Payment("magnitni nakolenki", 45.68m) });

            Customer goshoCopy = gosho;
            gosho.FirstName = "Genka";
            Console.WriteLine(gosho);
            Console.WriteLine(goshoCopy);
            Console.WriteLine(goshoCopy == gosho);
            Console.WriteLine(gosho.Equals(goshoCopy));
            Console.WriteLine(Object.ReferenceEquals(gosho, goshoCopy));

            goshoCopy = (Customer)gosho.Clone();
            goshoCopy.FirstName = "Gosho";
            goshoCopy.Payments.Add(new Payment("soleti", 2.03m));
            Console.WriteLine(gosho);
            Console.WriteLine(goshoCopy);
            Console.WriteLine(goshoCopy == gosho);
            Console.WriteLine(gosho.Equals(goshoCopy));
            Console.WriteLine(Object.ReferenceEquals(gosho, goshoCopy));
        }
        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);
            }
        }
Example #13
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);
        }
Example #14
0
        public static void Main()
        {
            Customer pesho1 = new Customer("Peter", "Ivanov", "Petrov", "8010201020", "AAA 5", "0888 123 456", "*****@*****.**",
                new List<Payment>{new Payment("Vnoska", 150.99)}, CustomerType.OneTime);

            Customer pesho2 = (Customer) pesho1.Clone();

            Console.WriteLine(pesho1.Equals(pesho2));
            Console.WriteLine(pesho1.CompareTo(pesho2) + "\n");

            pesho2.Id = "8010201021";

            Console.WriteLine(pesho1.Equals(pesho2));
            Console.WriteLine(pesho1.CompareTo(pesho2) + "\n");
        }
 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());
 }
Example #16
0
        static void Main()
        {
            Customer Ivan = new Customer(3, "Ivan", "Petrov", "Goshov", "Sofia, Mladost", "+359-897-687-52", "*****@*****.**", CustomerType.Golden, new List<Payment>() { new Payment("Lenovo", 533), new Payment("Samsung", 789), });
            Customer Petar = new Customer(2, "Petar", "Goshov", "Ivanov", "Sofia, Lulin", "+359-897-534-59", "*****@*****.**", CustomerType.OneTime, new List<Payment>() { new Payment("Acer", 533), new Payment("MSI", 789), });
            Customer Ivan4o = new Customer(1, "Ivan", "Petrov", "Goshov", "Sofia, Iztok", "+359-897-687-49", "*****@*****.**", CustomerType.Diamond, new List<Payment>() { new Payment("Asus", 533), new Payment("HP", 789), });
            Customer IvanCopy = (Customer)Ivan.Clone();

            Console.WriteLine(Ivan + "\n");

            Console.WriteLine(Ivan.Equals(Petar));
            Console.WriteLine(Ivan.Equals(Ivan4o));
            Console.WriteLine(Ivan.Equals(IvanCopy) + "\n");

            Console.WriteLine(Ivan.CompareTo(IvanCopy));
            Console.WriteLine(Ivan.CompareTo(Ivan4o));
        }
Example #17
0
        static void Main()
        {
            Customer pesho = new Customer("Pesho", "Peshev", "Peshliyski", 8012213456, "Peshovitza 5", "02/3456789", "*****@*****.**", new List<Payment>(), CustomerType.Regular);
            pesho.Payments.Add(new Payment("Vinkel", 100));
            pesho.Payments.Add(new Payment("Armatura", 150));
            Console.WriteLine(pesho);
            Console.WriteLine("Payments:");
            foreach (Payment item in pesho.Payments)
            {
                Console.WriteLine("- {0} - {1} BGN", item.ProductName, item.Price);
            }
            Console.WriteLine(new string('=', 30));

            Customer gosho = pesho.Clone() as Customer;
            gosho.FirstName = "Gosho";
            gosho.ID = 7704024567;
            gosho.Email = "*****@*****.**";
            gosho.Payments.Add(new Payment("Ankeri", 100));

            Console.WriteLine(gosho);
            Console.WriteLine("Payments:");
            foreach (Payment item in gosho.Payments)
            {
                Console.WriteLine("- {0} - {1} BGN", item.ProductName, item.Price);
            }
            Console.WriteLine(new string('=', 30));

            if (pesho.CompareTo(gosho) > 0)
            {
                Console.WriteLine("Customer is first, compared to the given criteria.");
            }
            else if (pesho.CompareTo(gosho) < 0)
            {
                Console.WriteLine("Customer is last, compared to the given criteria.");
            }
            else
            {
                Console.WriteLine("Customers are equal.");
            }

            Console.WriteLine("First equals second: " + pesho.Equals(gosho));
            Console.WriteLine("First == second: " + (pesho == gosho));
            Console.WriteLine("First != second: " + (pesho != gosho));

            Console.WriteLine("First's hash: " + pesho.GetHashCode());
            Console.WriteLine("Second's hash: " + gosho.GetHashCode());
        }
Example #18
0
        static void Main(string[] args)
        {
            Customer.Customer[] customers = new Customer.Customer[2];
            customers[0] = new Customer.Customer("James Bond", 0);
            customers[1] = new Customer.Customer("Goldfinger", 1);

            for (int i = 0; i < customers.Length; i++)
                customers[i].PrintCustomer();

            customers[0].Deposite(0, 100);
            customers[0].Deposite(1, 300);

            customers[1].Deposite(0, 20000);
            customers[1].Deposite(1, 50000);

            for (int i = 0; i < customers.Length; i++)
                customers[i].PrintCustomer();
        }
        static void Main()
        {
            var pesho = new Customer("Petar", "Ivanov", "Mitrev", 123456789);
            var pesho2 = new Customer("Petar", "Ivanov", "Mitrev", 123456788);
            var gosho = new Customer("Gosho", "Ivanov", "Shopov", 100000001);

            Payment[] payments =
            {
                new Payment("book", 25.5m),
                new Payment("phone", 250.89m),
                new Payment("tablet", 500),
                new Payment("phone", 250.89m),
                new Payment("tablet", 500)
            };

            foreach (var payment in payments)
            {
                pesho.AddPayment(payment);
                gosho.AddPayment(payment);
            }

            var petarCloning = (Customer)pesho.Clone();

            Console.WriteLine(pesho == gosho);
            Console.WriteLine(pesho == pesho);
            Console.WriteLine(pesho == petarCloning);

            Console.WriteLine(pesho.CompareTo(gosho));
            Console.WriteLine(pesho2.CompareTo(pesho));
            Console.WriteLine(pesho.CompareTo(petarCloning));

            Console.WriteLine("=------------------------------------------");

            Customer cloning = (Customer)pesho.Clone();

            pesho.Payments[0].Price = 200;
            cloning.Payments[0].Price = 100000;

            Console.WriteLine("Pesho cloninig:\n{0}", cloning.Payments[0].Price);
            Console.WriteLine("Pesho:\n{0}", pesho.Payments[0].Price);
        }
Example #20
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()));
        }
Example #21
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");
        }
Example #22
0
        static void Main(string[] args)
        {
            Customer.Customer[] customers = new Customer.Customer[2];
            customers[0] = new Customer.Customer("James Bond", 0);
            customers[1] = new Customer.Customer("Goldfinger", 1);

            for (int i = 0; i < customers.Length; i++)
            {
                customers[i].PrintCustomer();
            }

            customers[0].Deposite(0, 100);
            customers[0].Deposite(1, 300);

            customers[1].Deposite(0, 20000);
            customers[1].Deposite(1, 50000);

            for (int i = 0; i < customers.Length; i++)
            {
                customers[i].PrintCustomer();
            }
        }
Example #23
0
        static void Main(string[] args)
        {
            Customer originalCustumer = new Customer("Krum", "Stefanov", "Georgiev", "*****@*****.**",
                "+23426363", "Sofia Aleko No32", 1,
                    new List<Payment>() { new Payment("Taxes", 152), new Payment("Car Leasing", 3152) },
                        CustumerType.Regular);

            Customer clonedCustomer = (Customer)originalCustumer.Clone();
            clonedCustomer.FirstName = "Aleksander";
            clonedCustomer.Id = 2;

            List<Customer> customers = new List<Customer>(){originalCustumer, clonedCustomer};

            Console.WriteLine("NewCustomer - {0}", clonedCustomer);

            Console.WriteLine("Original Customer - {0}", originalCustumer);

            var orderedCustumers = customers.OrderBy(cust => cust).ToList();
            foreach (Customer customer in orderedCustumers)
            {
                Console.WriteLine(customer);
            }
        }
Example #24
0
        static void Main(string[] args)
        {
            Console.WriteLine("**********Welcome to ___ Bank!**********");
            Console.Write("Do want to add Account? (y/n): ");
            char choice = Convert.ToChar(Console.ReadLine());

            Customer.Customer cust = new Customer.Customer();
            BL bl = new BL();

            Account.Account account = new Account.Account();

            if (choice.Equals('y') || choice.Equals('Y'))
            {
                account = bl.addAccount(ref cust);
            }
            else
            {
                //Console.WriteLine("Already have an account?\nEnter Account no: ");
            }

            bl.displayAccount(account);
            bl.selectOption(account);
        }
Example #25
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));
        }
Example #26
0
        public static void Main()
        {
            try
            {
                Customer stefan = new Customer("Stefan", "Ivanov", "Stefanov", "1234567890", "Sofia", "+359888777666", "*****@*****.**", new Payment("VGA", 260.0m), CustomerType.Diamond);

                Customer copyOfStefan = stefan;

                Customer ivan = stefan.Clone() as Customer;
                ivan.FirstName = "Ivan";
                ivan.AddPayment(new Payment("CPU", 354.12m));
                
                Console.WriteLine(stefan);
                Console.WriteLine("Deep copy:\n{0}", ivan);
                Console.WriteLine("Equals (different customers): {0}", stefan.Equals(ivan));
                Console.WriteLine("Compare (different customers): {0}", stefan.CompareTo(ivan));
                Console.WriteLine("Equals (different customers, same reference): {0}", stefan.Equals(copyOfStefan));
                Console.WriteLine("Compare (different customers, same reference): {0}", stefan.CompareTo(copyOfStefan));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        } 
Example #27
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));
 }
Example #28
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);
            }
        }
Example #29
0
        static void Main(string[] args)
        {
            int personID = 0;
            int workerID = 100;

            Employee.Employee johnS     = new Employee.Employee(personID++, "John", "Smith", "03/24/1992", "Sales", workerID++, "11/12/2010");
            Customer.Customer customer1 = new Customer.Customer(personID++, "Andrew", "Beans", "04/26/1985", "123 Parkway Lane", "Jerky", "Nevada");
            Employee.Employee codyG     = new Employee.Employee(personID++, "Cody", "Godfreed", "05/07/2000", "Human Resources", workerID++, "08/05/2017");
            Employee.Employee harryP    = new Employee.Employee(personID++, "Harry", "Potter", "11/13/1974", "Sales", workerID++, "06/30/1990");
            Customer.Customer customer2 = new Customer.Customer(personID++, "Nick", "Sharp", "12/26/1983", "456 Jungle Avenue", "Spoon", "Californa");
            Customer.Customer customer3 = new Customer.Customer(personID++, "Phil", "Write", "05/01/1957", "789 Space Boulevard", "Townsvill", "Oregon");
            Customer.Customer customer4 = new Customer.Customer(personID++, "Cleo", "Jones", "04/19/1935", "101 Teachers Way", "Springston", "Georgia");
            Employee.Employee zakJ      = new Employee.Employee(personID++, "Zak", "Jack", "02/22/1992", "Marketing", workerID++, "01/24/2008");
            Customer.Customer customer5 = new Customer.Customer(personID++, "Jessica", "Whyzen", "06/20/1974", "258 Terror Drive", "Hampton", "Maine");
            Employee.Employee zackH     = new Employee.Employee(personID++, "Zack", "Hound", "09/03/1969", "Public Relations", workerID++, "07/23/2018");

            Employee.Employee[] store   = new Employee.Employee[5];
            Customer.Customer[] clients = new Customer.Customer[5];

            store[0] = johnS;
            store[1] = codyG;
            store[2] = harryP;
            store[3] = zakJ;
            store[4] = zackH;

            clients[0] = customer1;
            clients[1] = customer2;
            clients[2] = customer3;
            clients[3] = customer4;
            clients[4] = customer5;

            //Sorts Employees
            Employee.Employee[] storeHold = new Employee.Employee[1];
            for (int i = 0; i < store.Length; i++)
            {
                for (int j = 0; j < store.Length; j++)
                {
                    int c = string.Compare(store[j].firstName, store[i].firstName);
                    if (c == 1)
                    {
                        storeHold[0] = store[i];
                        store[i]     = store[j];
                        store[j]     = storeHold[0];
                    }
                }
            }

            //Sorts Clients
            Customer.Customer[] clientHold = new Customer.Customer[1];
            for (int i = 0; i < clients.Length; i++)
            {
                for (int j = 0; j < clients.Length; j++)
                {
                    int c = string.Compare(clients[j].firstName, clients[i].firstName);
                    if (c == 1)
                    {
                        clientHold[0] = clients[i];
                        clients[i]    = clients[j];
                        clients[j]    = clientHold[0];
                    }
                }
            }

            Console.WriteLine("This stores employees include:");
            for (int i = 0; i < store.Length; i++)
            {
                Console.WriteLine($"PID: {store[i].ID} First Name: {store[i].firstName} Last Name: {store[i].lastName} Date of Birth: {store[i].DOB} " +
                                  $"Department: {store[i].department} Employee ID: {store[i].employeeID} Date Employeed: {store[i].DOJ}");
            }

            Console.WriteLine("This stores clients include:");
            for (int t = 0; t < clients.Length; t++)
            {
                Console.WriteLine($"PID: {clients[t].ID} First Name: {clients[t].firstName} Last Name: {clients[t].lastName} Date of Birth:{clients[t].DOB} " +
                                  $"Address: {clients[t].address} City: {clients[t].city} State: {clients[t].state}");
            }
        }
        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));
        }
Example #31
0
 public object Clone()
 {
     Customer clonedCustomer = new Customer(this.FirstName, this.MiddleName, this.LastName,
         this.Email, this.MobilePhone, this.PermanentAddress, this.Id,
         new List<Payment>(this.Payments), this.CustomerType);
     return clonedCustomer;
 }