public static void ShowAll() //where U : ScientificAssociation<Student> //where V : ScientificAssociation<Employee> { bool flag = false; WriteLine("( AssociationID, TypeOfAssociation, Title, StudyArea )"); foreach (object ourAssotiation in Journal) { if (ourAssotiation is ScientificAssociation <Student> ) { ScientificAssociation <Student> tmp = ourAssotiation as ScientificAssociation <Student>; tmp.ShowInfo(); flag = true; } else if (ourAssotiation is ScientificAssociation <Employee> ) { ScientificAssociation <Employee> tmp = ourAssotiation as ScientificAssociation <Employee>; tmp.ShowInfo(); flag = true; } } MainActions.NoExistMassege(flag, TypeOfEntity.Association, AmountOfEntities.Several); }
// Using delegate. public static void ShowAssociationParticipants() { int ourID; bool flag = false; Show ourShowInfo; MainActions.ChoosenTypeOfAssociation(out TypeOfEntity ourTypeOfEntity); Write("Введите ID обьединения : "); ourID = MainActions.GetCorrectPositiveInt(); switch (ourTypeOfEntity) { case TypeOfEntity.Student: { foreach (ScientificAssociation <Student> ourAssociation in ListOfAssociations.Journal) { if (ourID == ourAssociation.AssociationID) { ourShowInfo = ourAssociation.ShowParticipants; ourShowInfo?.Invoke(); flag = true; break; } } } break; case TypeOfEntity.Employee: { foreach (ScientificAssociation <Employee> ourAssociation in ListOfAssociations.Journal) { if (ourID == ourAssociation.AssociationID) { ourAssociation.ShowParticipants(); flag = true; break; } } } break; } MainActions.NoExistMassege(flag, TypeOfEntity.Association, AmountOfEntities.One); }
public static void ShowAll() { bool flag = false; WriteLine(" (ID работника, Имя, Фамилия, Должность, Стаж) "); for (int i = 0; i < ActualNumberOfEmployees; i++) { if (journal[i] != null) { MainActions.ShowEmployeeInfo(journal[i]); flag = true; } } MainActions.NoExistMassege(flag, TypeOfPerson.Employee, AmountOfPersons.Several); }
public static void ShowAll() { bool flag = false; WriteLine("(ID студента, Факультет, Группа, Имя, Фамилия, Успеваемость)"); for (int i = 0; i < ActualNumberOfStudents; i++) { if (journal[i] != null) { MainActions.ShowStudentInfo(journal[i]); flag = true; } } MainActions.NoExistMassege(flag, TypeOfEntity.Student, AmountOfEntities.Several); }
public static void ShowAllBooks(List <Book> listOfBooks) { bool flag = false; WriteLine("( ID, title, year, price($) )"); foreach (Book ourBook in listOfBooks.ToArray()) { string tmp = ourBook.ToString("Standart", new CultureInfo("en-US")); WriteLine(tmp); } if (listOfBooks.Count != 0) { flag = true; } MainActions.NoExistMassege(flag, TypeOfEntity.Book, AmountOfEntities.Several); }
public static void RemoveBook(List <Book> listOfBooks) { Write("Введите ID книги : "); int ourBookID = MainActions.GetCorrectPositiveInt(); bool flag = false; foreach (Book ourBook in listOfBooks.ToArray()) { if (ourBook.BookID == ourBookID) { listOfBooks.Remove(ourBook); flag = true; } } MainActions.NoExistMassege(flag, TypeOfEntity.Book, AmountOfEntities.One); }
public static void FindStudentByID() { bool flag = false; int ourID; Write("Введите ID студента: "); ourID = MainActions.GetCorrectPositiveInt(); foreach (Student ourStudent in ListOfStudents.journal.ToArray()) { if (ourStudent.PersonID == ourID) { ourStudent.ShowInfo(); flag = true; } } MainActions.NoExistMassege(flag, TypeOfPerson.Student, AmountOfPersons.One); }
public static void FindEmployeeByID() { bool flag = false; int ourID; Write("Введите ID сотрудника: "); ourID = MainActions.GetCorrectPositiveInt(); foreach (Employee ourEmployee in ListOfEmployees.journal.ToArray()) { if (ourEmployee.PersonID == ourID) { ourEmployee.ShowInfo(); flag = true; } } MainActions.NoExistMassege(flag, TypeOfPerson.Employee, AmountOfPersons.One); }
public static void RemoveEmployee() { bool flag = false; int ourInputID; Write("Введите ID сотрудника : "); ourInputID = MainActions.GetCorrectPositiveInt(); foreach (Employee ourEmployee in ListOfEmployees.Journal.ToArray()) //that's possible if List -> Array ... but for my new class it isn't necc { if (ourInputID == ourEmployee.PersonID) { ListOfEmployees.Remove(ourEmployee); flag = true; } } MainActions.NoExistMassege(flag, TypeOfEntity.Employee, AmountOfEntities.One); }
public static void RemoveStudent() { bool flag = false; int ourInputID; Write("Введите ID студента : "); ourInputID = MainActions.GetCorrectPositiveInt(); // That's possible if List -> Array ... but for my new class it isn't necessary. foreach (Student ourStudent in ListOfStudents.journal.ToArray()) { if (ourInputID == ourStudent.PersonID) { ListOfStudents.Remove(ourStudent); flag = true; } } MainActions.NoExistMassege(flag, TypeOfPerson.Student, AmountOfPersons.One); }
public void ShowParticipants() //тут ошибка! { bool flag = false; WriteLine("(AssociationID, TypeOfAssociation, Title, StudyArea )"); ShowInfo(); if (typeOfEntity == TypeOfEntity.Student) { WriteLine("(ID студента, Факультет, Группа, Имя, Фамилия, Успеваемость)"); } else if (typeOfEntity == TypeOfEntity.Employee) { WriteLine("(ID работника, Имя, Фамилия, Должность, Стаж)"); } for (var i = 0; i < ActualNumberOfParticipants; i++) { if (membersArray[i] != null) { if (typeOfEntity == TypeOfEntity.Student) { //Student ourStuedent = membersArray[i] as Student; MainActions.ShowStudentInfo(membersArray[i] as Student); } else if (typeOfEntity == TypeOfEntity.Employee) { //Employee ourEmployee = membersArray[i] as Employee; MainActions.ShowEmployeeInfo(membersArray[i] as Employee); } flag = true; } } MainActions.NoExistMassege(flag, TypeOfEntity.Student, AmountOfEntities.Several); }
public static void ShowBookInfo(List <Book> listOfBooks) { int ourID; bool flag = false; Write("Введите ID книги : "); ourID = MainActions.GetCorrectPositiveInt(); foreach (Book ourBook in listOfBooks.ToArray()) { if (ourBook.BookID == ourID) { string ourAnswer; ourAnswer = ourBook.ToString("Full", new CultureInfo("en-US")); WriteLine(ourAnswer); flag = true; break; } } MainActions.NoExistMassege(flag, TypeOfEntity.Book, AmountOfEntities.One); }
// Here i use delegate. public static void FindStudentByID() { bool flag = false; int ourID; Show ourShowInfo; Write("Введите ID студента: "); ourID = MainActions.GetCorrectPositiveInt(); foreach (Student ourStudent in ListOfStudents.Journal) { if (ourStudent.PersonID == ourID) { ourStudent.Move += (ms) => WriteLine(ms); ourShowInfo = ourStudent.ShowInfo; // Check for null and execute. ourShowInfo?.Invoke(); flag = true; } } MainActions.NoExistMassege(flag, TypeOfEntity.Student, AmountOfEntities.One); }
public static void ShowAll(UniversityElements ourElement) { bool flag = false; string ourFaculty; int ourFacultyNumber; ourFaculty = MainActions.ChoosenFaculty(out ourFacultyNumber); switch (ourElement) { case UniversityElements.Faculty: { WriteLine("(ID студента, Факультет, Группа, Имя, Фамилия)"); foreach (Student ourStudent in ListOfStudents.journal.ToArray()) { if (ourStudent.Faculty == ourFaculty) { MainActions.ShowStudentInfo(ourStudent); flag = true; } } } break; case UniversityElements.Specialty: { string ourSpecialty; ourSpecialty = MainActions.ChoosenSpecialty(ourFacultyNumber); WriteLine("(ID студента, Факультет, Группа, Имя, Фамилия)"); foreach (Student ourStudent in ListOfStudents.journal.ToArray()) { if (ourStudent.Specialty == ourSpecialty) { MainActions.ShowStudentInfo(ourStudent); flag = true; } } } break; case UniversityElements.Group: { string ourSpecialty; string ourGroup; int ourYear; ourSpecialty = MainActions.ChoosenSpecialty(ourFacultyNumber); ourYear = MainActions.ChoosenYear(); ourGroup = MainActions.ChoosenGroup(); WriteLine("(ID студента, Факультет, Группа, Имя, Фамилия)"); foreach (Student ourStudent in ListOfStudents.journal.ToArray()) { if (ourStudent.Group == ourGroup && ourStudent.Year == ourYear && ourStudent.Specialty == ourSpecialty) { MainActions.ShowStudentInfo(ourStudent); flag = true; } } } break; } MainActions.NoExistMassege(flag, TypeOfEntity.Student, AmountOfEntities.Several); }
public static void AddAssocation() { int amountOfParticipants; MainActions.ChoosenTypeOfAssociation(out TypeOfEntity ourTypeOfEntity); switch (ourTypeOfEntity) { case TypeOfEntity.Student: { ScientificAssociation <Student> ourAssociation = new ScientificAssociation <Student>(TypeOfEntity.Student); ourAssociation.SetInfo(); Write("Кол-во студентов(1-6) : "); amountOfParticipants = MainActions.GetCorrectPositiveInt(1, 6); for (int i = 0; i < amountOfParticipants; i++) { int ourID; bool flag = false; SomeException: Write($"Введите ID студента №{i + 1} : "); ourID = MainActions.GetCorrectPositiveInt(); foreach (Student ourStudent in ListOfStudents.Journal) { if (ourID == ourStudent.PersonID) { ourAssociation.Add(ourStudent); flag = true; } } MainActions.NoExistMassege(flag, TypeOfEntity.Student, AmountOfEntities.One); if (flag == false) { goto SomeException; } } ListOfAssociations.Add(ourAssociation); } break; case TypeOfEntity.Employee: { ScientificAssociation <Employee> ourAssociation = new ScientificAssociation <Employee>(TypeOfEntity.Employee); ourAssociation.SetInfo(); Write("Кол-во преподавателей(1-6) : "); amountOfParticipants = MainActions.GetCorrectPositiveInt(1, 6); for (int i = 0; i < amountOfParticipants; i++) { int ourID; bool flag = false; SomeException: Write($"Введите ID преподавателя №{i + 1} : "); ourID = MainActions.GetCorrectPositiveInt(); foreach (Employee ourEmployee in ListOfEmployees.Journal) { if (ourID == ourEmployee.PersonID) { ourAssociation.Add(ourEmployee); flag = true; } } MainActions.NoExistMassege(flag, TypeOfEntity.Employee, AmountOfEntities.One); if (flag == false) { goto SomeException; } } ListOfAssociations.Add(ourAssociation); } break; } }
static void Main(string[] args) { WriteLine("\t\t--------------BSUIR Students, employees and book List --------------"); while (true) { int mainChoice; GotoMainMenu: WriteLine("Menu:"); WriteLine("1. Списки студентов"); WriteLine("2. Списки сотрудников"); WriteLine("3. Библиотека"); WriteLine("4. Выход."); Write("\nВыберите пункт: "); mainChoice = MainActions.GetCorrectPositiveInt(1, 4); switch (mainChoice) { case 1: { ListOfStudents listOfStudents = new ListOfStudents(); while (true) { int firstChoice; WriteLine("Students Menu:"); WriteLine("1. Добавить студента"); WriteLine("2. Удалить студента"); WriteLine("3. Показать список студентов"); WriteLine("4. Найти студента по ID"); WriteLine("5. Вывести всех студентов с учетом успеваемости"); WriteLine("6. Вернуться в главное меню"); WriteLine("7. Выход."); Write("\nВыберите пункт: "); firstChoice = MainActions.GetCorrectPositiveInt(1, 7); Write("\n"); switch (firstChoice) { case 1: { Student addedStudent = new Student(); addedStudent.SetInfo(); ListOfStudents.Add(addedStudent); } break; case 2: { SwitchCaseActions.RemoveStudent(); } break; case 3: { int ourChoice3; WriteLine("\tВыберите один из пунктов: "); WriteLine("\t1. Показать всех студентов в университете"); WriteLine("\t2. Показать всех студентов факультета"); WriteLine("\t3. Показать всех студентов специальности"); WriteLine("\t4. Показать всех студентов группы"); Write("\tВвод : "); ourChoice3 = MainActions.GetCorrectPositiveInt(1, 4); // in range from 1 to 4 switch (ourChoice3) { case 1: { ListOfStudents.ShowAll(); } break; case 2: { bool flag = false; string ourFaculty; int ourFacultyNumber; ourFaculty = MainActions.ChoosenFaculty(out ourFacultyNumber); WriteLine("(ID студента, Факультет, Группа, Имя, Фамилия)"); foreach (Student ourStudent in ListOfStudents.journal.ToArray()) { if (ourStudent.Faculty == ourFaculty) { MainActions.ShowStudentInfo(ourStudent); flag = true; } } MainActions.NoExistMassege(flag, TypeOfPerson.Student, AmountOfPersons.Several); } break; case 3: { bool flag = false; string ourFaculty; int ourFacultyNumber; string ourSpecialty; ourFaculty = MainActions.ChoosenFaculty(out ourFacultyNumber); ourSpecialty = MainActions.ChoosenSpecialty(ourFacultyNumber); WriteLine("(ID студента, Факультет, Группа, Имя, Фамилия)"); foreach (Student ourStudent in ListOfStudents.journal.ToArray()) { if (ourStudent.Specialty == ourSpecialty) { MainActions.ShowStudentInfo(ourStudent); flag = true; } } MainActions.NoExistMassege(flag, TypeOfPerson.Student, AmountOfPersons.Several); } break; case 4: { bool flag = false; string ourFaculty; int ourFacultyNumber; string ourSpecialty; string ourGroup; int ourYear; ourFaculty = MainActions.ChoosenFaculty(out ourFacultyNumber); ourSpecialty = MainActions.ChoosenSpecialty(ourFacultyNumber); ourYear = MainActions.ChoosenYear(); ourGroup = MainActions.ChoosenGroup(); WriteLine("(ID студента, Факультет, Группа, Имя, Фамилия)"); foreach (Student ourStudent in ListOfStudents.journal.ToArray()) { if (ourStudent.Group == ourGroup && ourStudent.Year == ourYear && ourStudent.Specialty == ourSpecialty) { MainActions.ShowStudentInfo(ourStudent); flag = true; } } MainActions.NoExistMassege(flag, TypeOfPerson.Student, AmountOfPersons.Several); } break; } } break; case 4: { SwitchCaseActions.FindStudentByID(); } break; case 5: { ListOfStudents.SortByProgress(); ListOfStudents.ShowAll(); if (ListOfStudents.ActualNumberOfStudents == 0) { WriteLine("( There is no any students )"); } } break; case 6: { goto GotoMainMenu; } //break; case 7: { Environment.Exit(0); } break; } } } break; case 2: { while (true) { int secondChoice; WriteLine("Employees Menu:"); WriteLine("1. Добавить сотрудника"); WriteLine("2. Удалить сотрудника"); WriteLine("3. Показать список сотрудников"); WriteLine("4. Найти сотрудника по ID"); WriteLine("5. Вывести всех сотрудников с учетом стажа работы"); WriteLine("6. Вернуться в главное меню"); WriteLine("7. Выход."); Write("\nВыберите пункт: "); secondChoice = MainActions.GetCorrectPositiveInt(1, 7); switch (secondChoice) { case 1: { SwitchCaseActions.AddEmployee(); } break; case 2: { SwitchCaseActions.RemoveEmployee(); } break; case 3: { ListOfEmployees.ShowAll(); } break; case 4: { SwitchCaseActions.FindEmployeeByID(); } break; case 5: { ListOfEmployees.SortByWorkExperience(); ListOfEmployees.ShowAll(); } break; case 6: { goto GotoMainMenu; } //break; case 7: { Environment.Exit(0); } break; } } } break; case 3: { List <Book> listOfBooks = new List <Book>(); while (true) { int thirdChoice; WriteLine("Libruary Menu : "); WriteLine("1. Добавить книгу"); WriteLine("2. Удалить книгу"); WriteLine("3. Показать все книги"); WriteLine("4. В главное меню"); WriteLine("5. Выход."); Write("Ввод : "); thirdChoice = MainActions.GetCorrectPositiveInt(1, 5); switch (thirdChoice) { case 1: { Book newBook = new Book(listOfBooks.Count); newBook.SetInfo(); listOfBooks.Add(newBook); } break; case 2: { Write("Введите ID книги : "); int ourBookID = MainActions.GetCorrectPositiveInt(); bool flag = false; foreach (Book ourBook in listOfBooks.ToArray()) { if (ourBook.BookID == ourBookID) { listOfBooks.Remove(ourBook); flag = true; } } if (flag == false) { WriteLine("( There's no such book )"); } } break; case 3: { bool flag = false; WriteLine("( ID, title, year, price )"); foreach (Book ourBook in listOfBooks.ToArray()) { ourBook.ShowInfo(); flag = true; } if (flag == false) { WriteLine("( There's no any book )"); } } break; case 4: { goto GotoMainMenu; } //break; case 5: { Environment.Exit(0); } break; } } } break; case 4: { Environment.Exit(0); } break; } } }