public bool ContainsCustomer(Customer customer) { if (customers.Contains(customer) == true) { return true; } else { return false; } }
public CustomerService() { Customer customer1 = new Customer("login1", "Fritz", "Müller", 20, Gender.MALE); Customer customer2 = new Customer("login2", "Vivian", "Auer", 40, Gender.FEMALE); Customer customer3 = new Customer("login3", "Susi", "Sorglos", 30, Gender.FEMALE); Customer customer4 = new Customer("login4", "Martin", "Auer", 18, Gender.MALE); customers.Add(customer1); customers.Add(customer2); customers.Add(customer3); customers.Add(customer4); }
/// <summary> /// Deletes the given <paramref name="customer"/>. /// </summary> /// <param name="customer">customer to delete</param> /// <returns>true if the customer has been deleted, false otherwise.</returns> public bool DeleteCustomer(Customer customer) { // Check if we have a customer in our list. // If we don't have one, we return false as // the customer hasn't been deleted actually. if (ContainsCustomer(customer)) { // Remove the customer. // We could also directly return the result of Remove() customers.Remove(customer); // Return true to communicate the result return true; } // Return false if the customer could not be found return false; }
private bool IsMale(Customer customer) { return customer.Gender == Gender.MALE; }
private bool IsAdult(Customer customer) { return customer.Age >= 18; }