public Boolean addStudent(Student aStudent) { Boolean success = false; if (!myList.Contains(aStudent)) { myList.Prepend(aStudent); success = true; } return success; }
/** * YOU HAVE TO COMPLETE THIS METHOD. * Displays a student's guest list * @param studentNum */ public void displayGuestList(int studentNum) { Student aStudent = new Student(studentNum, " "); if (myList.Contains(aStudent)) { myList.First(student => student.getStudentNum()==studentNum).displayGuestList(); } else{ Console.WriteLine("This student does not exist!"); } }
/** * YOU HAVE TO COMPLETE THIS METHOD. * Adds a guest to a student. Returns: * -1 if the student's name was not in the list * 0 if guest list is full * 1 if guest successfully added */ public int addGuest(int number, String guestName, String email) { int result = -1; Guest newGuest = new Guest(guestName, email); Student temp = new Student(number, " "); if (myList.Contains(temp)){ Student tmpStudent = (from student in myList where student.Equals(temp) select student).First(); if (tmpStudent.addGuest(newGuest)) { result = 1; } else { result = 0; } } return result; }
/** * Creates a new student object and passes it to the "engine" to be added * to the list. Duplicates are not allowed. * */ private void addStudent() { int studentNumber = getNumber("Enter student number: "); String name = getDetail("Enter student's name: "); Student aStudent = new Student(studentNumber, name); if (thisCeremony.addStudent(aStudent) == true) { Console.WriteLine(" Student " + name + " successfully added"); } else { Console.WriteLine(" Student " + name + " not added"); } }