Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()]));
- }
- }
- }
Add Comment
Please, Sign In to add comment