static void Main(string[] args) { BirthdayList birthdayList = new BirthdayList(); // initializing list class //making a couple BirthdayEntry objects BirthdayEntry e1 = new BirthdayEntry(); // default values BirthdayEntry e2 = new BirthdayEntry("George", "Mammos", "34324324", Convert.ToDateTime("01/01/0001")); birthdayList.AddEntry(e1); birthdayList.AddEntry(e2); birthdayList.AddEntry("John", "Doe", "3432432432", Convert.ToDateTime("01/01/2000")); // add a 3rd entry without making a BirthdayEntry object beforehand birthdayList.PrintAll(); birthdayList.RemoveEntry(3); //Should give out of index error message because we only have 0,1,2 atm ( i assume user knows we have zero index bounds in this scenario...) birthdayList.RemoveEntry(1); // Remove george birthdayList.PrintAll(); }
// Methods to add new entries // Add a newEntry that is already a BirthdayEntry object public void AddEntry(BirthdayEntry newEntry) { bList.Add(newEntry); }
// Add a newEntry from string/datetime inputs public void AddEntry(string firstName, string lastName, string telephone, DateTime dateOfBirth) { BirthdayEntry newEntry = new BirthdayEntry(firstName, lastName, telephone, dateOfBirth); bList.Add(newEntry); }
public BirthdayList(BirthdayEntry initialEntry) // constructor pou douleuei me to prwto entry (pio polu gia dokimi to eftiaxa...) { bList.Add(initialEntry); }