Created
December 14, 2018 14:51
-
-
Save khan-hasan/3110ce43e9e8377a205e97e7895a6dba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Customer | |
{ | |
string CustomerName; | |
// Constructor for Customer class | |
public Customer(string Name) | |
{ | |
CustomerName = Name; | |
} | |
} | |
class Customers | |
{ | |
// Create new array of Customer objects and assign it 5 new Customer objects | |
private internal Customer[] CustomerList = {Customer1 = new Customer("Bob"), | |
Customer2 = new Customer("Anne"), | |
Customer3 = new Customer("Tim"), | |
Customer4 = new Customer("Mary"), | |
Customer5 = new Customer("Harold") | |
}; | |
// Adds a new Customer object to CustomerList | |
public Add(Customer c) | |
{ | |
CustomerList.Add(c); | |
} | |
// Removes a Customer object with the specified CustomerName from the CustomerList if it exists. Otherwise, returns "Customer does not exist in our system." | |
public Remove(Customer c) | |
{ | |
if (Array.IndexOf(c) == null) | |
{ | |
Console.WriteLine("Customer does not exist in our system."); | |
} | |
else | |
{ | |
CustomerList.RemoveAt(IndexOf(CustomerList[IndexOf()])); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment