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() { 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); }
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); }
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); }
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); }
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); }
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)); }
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)); }
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)); }
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); }
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)); }
unsafe static 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)); }
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); }
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); }
static void Main(string[] args) { Customer baiIvan = new Customer("Ivan", "Vylkov", "Goshev", "8503285842", "Planet Earth", "+359987654321", "*****@*****.**", new List <Payment>() { new Payment("some product", 45.99m), new Payment("other some product", 55.49m) }, CustomerType.OneTime); Console.WriteLine(baiIvan); Customer baiYordan = baiIvan.Clone() as Customer; if (baiIvan == baiYordan) { Console.WriteLine("baiIvan equals baiGoran"); } else { Console.WriteLine("baiIvan and baiGoran not equals"); } Console.WriteLine(); Console.WriteLine("Changes baiGoran"); baiYordan.FirstName = "Yordan"; Console.WriteLine(baiYordan); Console.WriteLine(); Console.Write("Compare baiIvan and baiGoran: "); if (baiIvan.CompareTo(baiYordan) == 1) { Console.WriteLine("baiYordan"); } else if (baiIvan.CompareTo(baiYordan) == -1) { Console.WriteLine("baiIvan"); } Console.WriteLine(); if (baiIvan == baiYordan) { Console.WriteLine("baiIvan equals baiGoran"); } else { Console.WriteLine("baiIvan and baiGoran not equals"); } }
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); }
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); } }
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); }
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"); }
internal static void Main() { Customer thomas = new Customer("Thomas", "Anderson", "Rodriguez", "123456798", "America", "+1123456789", "*****@*****.**", new List<Payment>() { new Payment("Jacket", 99.99m), new Payment("Jeans", 49.99m) }, CustomerType.Diamond); Console.WriteLine("ToString()"); Console.WriteLine(thomas); Console.WriteLine("Clone()"); Customer copy = thomas.Clone() as Customer; Console.WriteLine(copy); Console.WriteLine("Is copy deep?"); copy.FirstName = "Lee"; copy.Payments = new List<Payment>() { new Payment("Shoes", 29.99m) }; copy.Id = "123456798"; Console.WriteLine(copy); Console.WriteLine(thomas); Console.WriteLine("Equals()"); Console.WriteLine(thomas.Equals(copy)); Customer third = thomas.Clone() as Customer; Console.WriteLine(thomas.Equals(third)); Console.WriteLine("== and !="); Console.WriteLine(thomas == copy); Console.WriteLine(thomas != copy); Console.WriteLine(thomas == third); Console.WriteLine(thomas != third); Console.WriteLine("CompareTo()"); Console.WriteLine(thomas.CompareTo(copy)); Console.WriteLine(thomas.CompareTo(third)); }
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()); }
static void Main(string[] args) { var paymentArrey = new Payment("Ford Mustang", 1000000m); var vankata = new Customer( "Ivan", "Petrov", "Georgiev", "8702053654", "Sofia-Lulin", "+35988815500", "*****@*****.**", CustomerType.OneTime, paymentArrey); var petar = vankata.Clone() as Customer; petar.FirstName = "Pe6o"; petar.LastName = "Pe6ev"; Console.WriteLine(petar); Console.WriteLine(vankata); var mariasPayments = new Payment("Masajen stol", 1000m); var maria = new Customer( "Maria", "Krasimirova", "Georgieva", "8599883854", "Nadejda5", "+359899339949", "*****@*****.**", CustomerType.Diamond, mariasPayments); var desi = maria.Clone() as Customer; desi.Id = "8234353535"; desi.LastName = "Bakarkov"; var customers = new List <Customer> { vankata, petar, maria, desi }; customers.Sort(); Console.WriteLine(string.Join("\n", customers)); }
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)); }
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()); }
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); }
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"); }
static void Main() { Customer firstCustomer = new Customer( "Peter", "Petrov", "Petrov", "8002044445", "0885885885", "*****@*****.**", CustomerType.Regular); Customer secondCustomer = new Customer( "Ivan", "Ivanov", "Ivanov", "9002042225", "0887885884", "*****@*****.**", CustomerType.Regular); Customer thirdCustomer = (Customer)secondCustomer.Clone(); thirdCustomer.FirstName = "Gosho"; thirdCustomer.EGN = "8212122246"; List <Customer> customers = new List <Customer>() { firstCustomer, secondCustomer, thirdCustomer }; customers.Sort(); foreach (var c in customers) { Console.WriteLine(c); } Console.WriteLine(secondCustomer); Console.WriteLine(thirdCustomer); Console.WriteLine(firstCustomer.Equals(secondCustomer)); }
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())); }
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()); }
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"); }
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(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); } }
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)); }
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.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.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); } }
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); } }
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)); }
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)); }
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)); }