コード例 #1
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);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Vakuu/CSharp
        static void Main()
        {
            var pesho = new Customer("Petar", "Petrov", "Petrov", 123456789);
            var ivan  = new Customer("Ivan", "Ivanov", "Ivanov", 123456789);

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

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

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

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

            Console.WriteLine(pesho.CompareTo(ivan));
            Console.WriteLine(pesho.CompareTo(petarCloning));

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

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

            Console.WriteLine("Pesho cloning:\n{0}", cloning.Payments[0].Price);
            Console.WriteLine("Pesho:\n{0}", pesho.Payments[0].Price);
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }