├── README.md ├── Customer.cs ├── CustomerManager.cs └── Program.cs /README.md: -------------------------------------------------------------------------------- 1 | # ClassMetotDemo -------------------------------------------------------------------------------- /Customer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ClassMetotDemo 8 | { 9 | class Customer 10 | { 11 | public int CustomerID { get; set; } 12 | public string FirstName { get; set; } 13 | public string LastName { get; set; } 14 | public string PhoneNumber { get; set; } 15 | public string Address { get; set; } 16 | public string Balance { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /CustomerManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ClassMetotDemo 8 | { 9 | class CustomerManager 10 | { 11 | List cList = new List { }; 12 | 13 | public void GetCustomerList() 14 | { 15 | Console.WriteLine("\nList of all registered customers: "); 16 | int count = 1; 17 | foreach (var c in cList) 18 | { 19 | Console.WriteLine(count +"-"+ c.FirstName + c.LastName); 20 | count++; 21 | } 22 | Console.WriteLine(); 23 | } 24 | 25 | public void GetCustomer(Customer c) 26 | { 27 | Console.WriteLine("Information of customer ID {0}: ", c.CustomerID); 28 | Console.WriteLine("- First Name: {1} \n- Last Name: {2} \n- Phone Number: {3} \n- Address: {4} \n- Balance: {5} \n ", 29 | c.CustomerID, 30 | c.FirstName, 31 | c.LastName, 32 | c.PhoneNumber, 33 | c.Address, 34 | c.Balance); 35 | } 36 | 37 | public void AddCutomer(Customer c) 38 | { 39 | cList.Add(c); 40 | Console.WriteLine("{0} {1} has been added.", c.FirstName, c.LastName); 41 | } 42 | 43 | public void DeleteCustomer(Customer c) 44 | { 45 | cList.Remove(c); 46 | Console.WriteLine("Customer ID:{0} has been deleted \n", c.CustomerID); 47 | Console.WriteLine("Customer list updated."); 48 | GetCustomerList(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace ClassMetotDemo 8 | { 9 | class Program 10 | { 11 | static void Main(string[] args) 12 | { 13 | Customer c1 = new Customer 14 | { 15 | CustomerID = 1, 16 | FirstName = "Harry", 17 | LastName = "Potter", 18 | PhoneNumber = "1212121212", 19 | Address = "The Cupboard under the Stairs, + PRivet Drive, Little Whinging SURREY", 20 | Balance = "£ 10.000" 21 | }; 22 | 23 | Customer c2 = new Customer 24 | { 25 | CustomerID = 2, 26 | FirstName = "Hermione", 27 | LastName = "Granger", 28 | PhoneNumber = "2323232323", 29 | Address = "Hampstead, London.", 30 | Balance = "£ 15.070" 31 | }; 32 | 33 | Customer c3 = new Customer 34 | { 35 | CustomerID = 3, 36 | FirstName = "Ron", 37 | LastName = "Weasley", 38 | PhoneNumber = "3434343434", 39 | Address = "Ottery St. Catchpole, Devon.", 40 | Balance = "£ 8.930" 41 | }; 42 | 43 | Customer c4 = new Customer 44 | { 45 | CustomerID = 4, 46 | FirstName = "Sirius", 47 | LastName = "Black", 48 | PhoneNumber = "4545454545", 49 | Address = "12 Grimmauld Place, London.", 50 | Balance = "£ 11.642" 51 | }; 52 | 53 | CustomerManager customerManager = new CustomerManager(); 54 | customerManager.AddCutomer(c1); 55 | customerManager.AddCutomer(c2); 56 | customerManager.AddCutomer(c3); 57 | customerManager.AddCutomer(c4); 58 | 59 | customerManager.GetCustomerList(); 60 | customerManager.GetCustomer(c1); 61 | customerManager.DeleteCustomer(c3); 62 | 63 | Console.ReadLine(); 64 | } 65 | } 66 | } 67 | --------------------------------------------------------------------------------