public static void UniverHW() { University univer = new University(); var techHeadmaster = new HeadOfDepartment("Albus", "Dumbledore", UniversityDepartment.Tech, AllExistingGenders.Male); var mathHeadmaster = new HeadOfDepartment("Victoria", "Vector", UniversityDepartment.Math, AllExistingGenders.Female); var histHeadmaster = new HeadOfDepartment("Bobby", "Pins", UniversityDepartment.History, AllExistingGenders.Male); var techTeacher = new Teacher("Severus", "Snape", UniversityDepartment.Tech, AllExistingGenders.Male); var mathTeacher = new Teacher("Minerva", "MacGonagall", UniversityDepartment.Math, AllExistingGenders.Female); var histTeacher = new Teacher("Anna", "Zauceva", UniversityDepartment.History, AllExistingGenders.Female); var techStudent = new Student("Sergei", "Tishkov", UniversityDepartment.Tech, AllExistingGenders.Male); var mathStudent = new Student("Aleksandr", "Maisak", UniversityDepartment.Math, AllExistingGenders.Male); var histStudent = new Student("Anton", "Akulenok", UniversityDepartment.History, AllExistingGenders.Male); univer.AddPeoples(techHeadmaster, techTeacher, techStudent, mathHeadmaster, mathTeacher, mathStudent, histHeadmaster, histTeacher, histStudent); Console.WriteLine("\n\nПробуем добавить такого же человека снова:"); var techTeacher1 = new Teacher("Severus", "Snape", UniversityDepartment.Tech, AllExistingGenders.Male); univer.AddPeople(techTeacher1); Console.WriteLine("\n\nА теперь заставим универ работать:"); univer.MakeUniversityWork(); Console.ReadKey(true); }
public HeadOfDepartment(HeadOfDepartment headOfDepartment) : base(headOfDepartment) { CountSubordinatess = headOfDepartment.CountSubordinatess; TeachingExperience = headOfDepartment.TeachingExperience; LoveOfWork = headOfDepartment.LoveOfWork; NameDepartment = headOfDepartment.NameDepartment; }
public void Count_AddOne_ShouldReturnCount1() { EmployeeList listOfEmployee = new EmployeeList(); HeadOfDepartment headOfDepartment = new HeadOfDepartment("Franz", "Abt1.", 7000); listOfEmployee.Insert(headOfDepartment); Assert.AreEqual(1, listOfEmployee.Count); }
public void FindEmployeeByName_NotFound_ShouldReturnIndexMinus1() { EmployeeList listOfEmployee = new EmployeeList(); HeadOfDepartment headOfDepartment = new HeadOfDepartment("Franz", "Abt1.", 7000); listOfEmployee.Insert(headOfDepartment); int index = listOfEmployee.FindEmployeeByName("Fritz"); Assert.AreEqual(-1, index); }
static void Main(string[] args) { University university = new University(); var student0 = new Student("Mike", "Polansky", Department.PowerEngineering); var student1 = new Student("Mary", "Beans", Department.Architectural); var student2 = new Student("Karl", "Peters", Department.InformationTechnologiesAndRobotics); var student3 = new Student("Sarah", "Hendrickson", Department.PowerEngineering); var student4 = new Student("Jasmine", "Caroll", Department.Architectural); university.AddPerson(student0); university.AddPerson(student1); university.AddPerson(student2); university.AddPerson(student3); university.AddPerson(student4); try { university.AddPerson(student0); } catch (Exception exception) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"Error occured while adding {student0}:\n\t{exception.Message}."); Console.ForegroundColor = ConsoleColor.White; } var professor0 = new Professor("Mathew", "Jenkins", Department.PowerEngineering); var professor1 = new Professor("Andy", "King", Department.Architectural); var professor2 = new Professor("Alice", "Smith", Department.InformationTechnologiesAndRobotics); university.AddPerson(professor0); university.AddPerson(professor1); university.AddPerson(professor2); var headProfessor0 = new HeadOfDepartment("Bob", "Thornton", Department.PowerEngineering); var headProfessor1 = new HeadOfDepartment("Katy", "Billigan", Department.Architectural); var headProfessor2 = new HeadOfDepartment("Ken", "Stampkos", Department.InformationTechnologiesAndRobotics); university.AddPerson(headProfessor0); university.AddPerson(headProfessor1); university.AddPerson(headProfessor2); Console.WriteLine(string.Join("\n", university.GetUniversityList())); Console.ReadKey(); }
public void GetEmployees_AddMany_ShouldReturnArrayInCorrectOrder() { EmployeeList listOfEmployee = new EmployeeList(); HeadOfDepartment headOfDepartment = new HeadOfDepartment("Franz", "Abt.1", 7000); Worker worker1 = new Worker("Hans", "Abt.1", 165, 12); Worker worker2 = new Worker("Sepp", "Abt.1", 145, 20); DepartmentalEmployee emp = new DepartmentalEmployee("Maria", "Abt.2", 1270); listOfEmployee.Insert(headOfDepartment); listOfEmployee.Insert(worker1); listOfEmployee.Insert(worker2); listOfEmployee.Insert(emp); Employee[] employees = listOfEmployee.GetEmployees(); Assert.AreEqual(4, employees.Length, "Es gibt 4 Mitarbeiter"); Assert.AreEqual("Franz", employees[0].Name, "Franz ist der Höchstverdiener"); Assert.AreEqual("Maria", employees[3].Name, "Maria ist in der Liste hinten"); }
public void GetSalaryOfDepartment_AddMany_ShouldReturnCorrectSalary() { EmployeeList listOfEmployee = new EmployeeList(); HeadOfDepartment headOfDepartment = new HeadOfDepartment("Franz", "Abt.1", 7000); Worker hans = new Worker("Hans", "Abt.1", 165, 12); Worker sepp = new Worker("Sepp", "Abt.1", 145, 20); DepartmentalEmployee maria = new DepartmentalEmployee("Maria", "Abt.2", 1270); listOfEmployee.Insert(headOfDepartment); listOfEmployee.Insert(hans); listOfEmployee.Insert(sepp); listOfEmployee.Insert(maria); double sumOfSalary = listOfEmployee.GetSalaryOfDepartment("Abt.1"); Assert.AreEqual(7000 * 1.2 + 165 * 12 + 145 * 20, sumOfSalary); Assert.AreEqual(1270, listOfEmployee.GetSalaryOfDepartment("Abt.2")); }
public void LoginAsHeadOfDepartment(DataSet dataSet) { //HeadOfDepartment headOfDepartment = HeadOfDepartment.Instance; AbstractFactory employeeFactory = FactoryProducer.getFactory("EmployeeFactory"); HeadOfDepartment headOfDepartment = (HeadOfDepartment)employeeFactory.getEmployee( "HeadOfDepartment"); headOfDepartment.FirstName = dataSet.Tables[0].Rows[0].ItemArray[0].ToString(); headOfDepartment.LastName = dataSet.Tables[0].Rows[0].ItemArray[1].ToString(); headOfDepartment.Id = dataSet.Tables[0].Rows[0].ItemArray[2].ToString(); headOfDepartment.Age = Convert.ToInt16(dataSet.Tables[0].Rows[0].ItemArray[3].ToString()); headOfDepartment.Username = dataSet.Tables[0].Rows[0].ItemArray[4].ToString(); headOfDepartment.Password = dataSet.Tables[0].Rows[0].ItemArray[5].ToString(); HeadOfDepartment_Form secretary_form = new HeadOfDepartment_Form(this.loginForm); secretary_form.ShowDialog(); }
public void FindEmployeeByName_AddMany_ShouldReturnCorrectIndices() { EmployeeList listOfEmployee = new EmployeeList(); HeadOfDepartment headOfDepartment = new HeadOfDepartment("Franz", "Abt.1", 7000); Worker worker1 = new Worker("Hans", "Abt.1", 165, 12); // 1980 Worker worker2 = new Worker("Sepp", "Abt.1", 145, 20); // 2900 DepartmentalEmployee emp = new DepartmentalEmployee("Maria", "Abt.2", 1979); listOfEmployee.Insert(headOfDepartment); listOfEmployee.Insert(worker1); listOfEmployee.Insert(worker2); listOfEmployee.Insert(emp); int index = listOfEmployee.FindEmployeeByName("Franz"); Assert.AreEqual(0, index); index = listOfEmployee.FindEmployeeByName("Fritz"); Assert.AreEqual(-1, index); index = listOfEmployee.FindEmployeeByName("Maria"); Assert.AreEqual(3, index); index = listOfEmployee.FindEmployeeByName("Hans"); Assert.AreEqual(2, index); index = listOfEmployee.FindEmployeeByName("Sepp"); Assert.AreEqual(1, index); }
static void Main(string[] args) { var persons = new object[10]; var student1 = new Student(170, 50, "Петров Петр Петрович", "О C#", "ООП", "ПГУ", "ФИТ", "18-ИТ-3", true); var student2 = new Student(192, 85, "Михайлов Михаил Милаилович", "О пиве", "СИАОД", "БГЭУ", "ИСФ", "19-ФМ", false); //var student3 = new Student("ЯП", "БНТУ", "МТФ", "18-ТР-2", false, 153, 62, "Иванов Иван Иваныч", "О JavaScript"); var student3 = new Student(176, 56, "Гасан Гаснович Гаснов", "О работе", "C#", "БГУ", "РТФ", "17-РТ", true); var studentCopy = new Student(176, 56, "Гасан Гаснович Гаснов", "О работе", "C#", "БГУ", "РТФ", "17-РТ", true); var teacher1 = new Teacher(180, 60, "Давыдов Давыдович Давыденко", "О многом", 1000, 45, "Бакалавр", "Математика"); var teacher2 = new Teacher(169, 56, "Петров Барис Иванович", "О детях", 600, 75, "Профессор", "Физика"); var teacher3 = new Teacher(188, 74, "Галеева Борина Адамовна", "О деньгах", 800, 120, "Магистр", "Языки программирования"); var headOfDepartment1 = new HeadOfDepartment(199, 91, "Поздняков Весемир Игорьевич", "О власти", 800, 120, "Магистр", "Языки программирования", 4, 10, true, "Кафедра ИСФ"); var headOfDepartment2 = new HeadOfDepartment(157, 75, "Азаренко Борислав Валерьевич", "О многом", 800, 120, "Магистр", "Языки программирования", 5, 20, false, "Кафедра РТФ"); var headOfDepartment3 = new HeadOfDepartment(183, 72, "Комарович Анжей Максимович", "О пиве", 800, 120, "Магистр", "Языки программирования", 8, 15, true, "Кафедра ГФ"); var headOfDepartment4 = new HeadOfDepartment(155, 45, "Фетченко Владислава Кирилловна", "О JavaScript", 800, 120, "Магистр", "Языки программирования", 10, 30, false, "Кафедра ФИТ"); var headOfteacherCopy = new Teacher(180, 60, "Давыдов Давыдович Давыденко", "О многом", 1000, 45, "Бакалавр", "Математика"); persons[0] = student1; persons[1] = student2; persons[2] = student3; persons[3] = teacher1; persons[4] = teacher2; persons[5] = teacher3; persons[6] = headOfDepartment1; persons[7] = headOfDepartment2; persons[8] = headOfDepartment3; persons[9] = headOfDepartment4; for (int i = 0; i < 10; i++) { Console.WriteLine(persons[i]); } HeadOfDepartment naiti = new HeadOfDepartment(155, 45, "Фетченко Владислава Кирилловна", "О JavaScript", 800, 120, "Магистр", "Языки программирования", 10, 30, false, "Кафедра ФИТ"); for (int i = 0; i < 10; i++) { if (persons[i].Equals(naiti) == true) { Console.WriteLine(""); Console.WriteLine(""); Console.WriteLine("найденный объект"); Console.WriteLine(persons[i]); } } /*foreach (var person in persons) * { * Console.WriteLine(person); * * if (person is Student) * { * var teacher = (Student)person; * Console.WriteLine($" Объекты равны? { teacher.Equals(new Student(176, 56, "Гасан Гаснович Гаснов", "О работе", "C#", "БГУ", "РТФ", "17-РТ", true))}"); * Console.WriteLine(); * } * }*/ Console.ReadKey(); }