Exemplo n.º 1
0
        public void TestDefaultConstructor()
        {
            Student student = new Student();

            Assert.AreEqual(student.Age, 8);

        }
Exemplo n.º 2
0
 internal static void Main(string[] args)
 {
     Student s = new Student();
     Teacher t = new Teacher();
     s.failedHandler += t.RemindFailure;
     s.Grade = 0;
 }
Exemplo n.º 3
0
        public void TestConstructorWithAge()
        {
            Student student = new Student(120);

            Assert.AreEqual(student.Age, 120);

        }
 public static void Main(string[] args)
 {
     Student s = new Student();
     s.Name = "shenwei";
     s.Name = "zhangxiaomao";
     Console.ReadKey();
 }
Exemplo n.º 5
0
        public List<Student> GetStudents()
        {
            List<Student> list1 = new List<Student>();
            // student1 is an instance of Student class
            Student student1 = new Student();
            Student student2 = new Student();
            list1.Add(student1);
            list1.Add(student2);

            return list1;
        }
Exemplo n.º 6
0
        public string RemindFailure(Student student, FailedEventArgs e)
        {
            string message =
                "Dear " + student.FirstName + " " + student.LastName + "," +
                " sorry, you have failed the exam. Your grade is: " +
                student.Grade.ToString() + " and this is what you said: " +
                e.ToString();

            Console.WriteLine(message);

            return message;
        }
Exemplo n.º 7
0
        static void TestStudent()
        {
            Student studentTest = new Student();
            // this is using a different constructor judging from the parameter passed in 
            Student studentTest2 = new Student(10);
            studentTest.Age = -2;
            Console.WriteLine(studentTest.Age);

            studentTest.LastName = "Joe";
            Console.WriteLine(studentTest.LastName);

            Console.Read();
        }
Exemplo n.º 8
0
        static void InsertStudent()
        {
            var student = new Student
            {
                Firstname = "Mehmet",
                Lastname = "Yıldız"
            };

            _serviceStudent.Insert(student);

            var addedStudent = _serviceStudent.GetById(student.Id);

            Console.WriteLine("Insert Test --> Firstname:{0} Lastname:{1} Id:{2}", addedStudent.Firstname, addedStudent.Lastname, addedStudent.Id);
        }
 static void Main(string[] args)
 {
     Console.WriteLine("Person--Student--ExStudent: ");
     Console.WriteLine();
     Person person1 = new Person("Vasia",26);
     Person person2 = new Person("Petia", 25);
     person1.ShowInfo();
     person2.ShowInfo();
     Person person3 = new Student("Vasia", 26,"BSU");
     Person person4 = new Student("Petia", 25, "BrSU");
     Console.WriteLine();
     person3.ShowInfo();
     person4.ShowInfo();
     Person person5 = new ExStudent("Vasia", 26, "BSU", "Brest");
     Person person6 = new ExStudent("Petia", 25, "BrSU", "Minsk");
     Console.WriteLine();
     person5.ShowInfo();
     person6.ShowInfo();
 }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            string name = Console.ReadLine();
            string surname = Console.ReadLine();
            string age = Console.ReadLine();

            int convertedAge = Int16.Parse(age);
            //int convertAgeMethod2 = Convert.ToInt16(age);
            //int convertAgeMethod3 = 0;

            //bool isParse = Int32.TryParse(age, out convertAgeMethod3);

            Student s = new Student(name, surname, convertedAge);
            Console.WriteLine(s);

            Console.WriteLine("");

            Console.ReadKey();
        }
Exemplo n.º 11
0
 static void Main(string[] args)
 {
     string sub;
     Person p1 = new Person();
     p1.Message();
     Student s1 = new Student();
     s1.SetAge(21);
     s1.Message();
     s1.ShowAge();
     Teacher t1 = new Teacher();
     t1.SetAge(30);
     t1.Message();
     t1.ShowAge();
     Console.WriteLine("Enter the subject:");
     sub = Console.ReadLine();
     t1.SetSub(sub);
     t1.Explain();
     Console.Read();
 }
Exemplo n.º 12
0
		static void Main()
		{
			Student nelson = new Student("nelson");

			Student gavin = new Student("gavin");

			Student jason = new Student("jason");

			Course introToCs = new Course("Intro to C#");

			Course introToCpp = new Course("Intro to C++");

			introToCs.AddStudent(nelson);
			introToCs.AddStudent(gavin);
			introToCs.AddStudent(jason);

			introToCpp.AddStudent(nelson);
			introToCpp.Display();
			introToCs.Display();

			Console.ReadKey();
		}
Exemplo n.º 13
0
Arquivo: Student.cs Projeto: PakVl/OOP
 public object DeepCopy()
 {
     Student stCopy = new Student(Name,Surname,DateOfBirth,FormEd,Group);
     stCopy.FieldListExam = ListExam;
     stCopy.FieldListTest = ListTest;
     return stCopy;
 }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            int    choice;
            int    count = 0;
            string ch    = "y";

            while (ch != "N" || ch != "n")
            {
                Console.Clear();
                Console.WriteLine("Press 1 to Create student profile ");
                Console.WriteLine("Press 2 to Search student");
                Console.WriteLine("Press 3 to Delete student record ");
                Console.WriteLine("Press 4 to list the top 03 of class ");
                Console.WriteLine("Press 4 to Mark Attendance");
                Console.WriteLine("Press 6 to View Attendance");
                Console.WriteLine("Enter Your Choice :");
                choice = Convert.ToInt32(Console.ReadLine());
                Student[] obj = new Student[40];
                if (choice == 1)
                {
                    obj[count] = new Student();
                    obj[count].addStudent();
                    count++;
                }
                if (choice == 2)
                {
                    Console.Clear();
                    Console.WriteLine("1 Search Students  By ID");
                    Console.WriteLine("2 Search Students  By Name");
                    Console.WriteLine("3 List All Students");

                    int opt;

                    opt = Convert.ToInt32(Console.ReadLine());

                    if (opt == 1)
                    {
                        Console.Clear();
                        Console.WriteLine("Enter ID : ");
                        string   id   = Console.ReadLine();
                        string[] data = File.ReadAllLines("Data.txt");

                        int       totalStudents = data.Length / 7;
                        int       tempO         = data.Length;
                        Student[] readObj       = new Student[totalStudents];

                        Console.WriteLine("ID \tName\tCGPA\tDepartment\tUniversity\tSemester\n\n\n");
                        int tempCount = 0;
                        for (int i = 0; i < totalStudents && tempCount != tempO; i++)
                        {
                            readObj[i]     = new Student();
                            readObj[i]._Id = data[tempCount];
                            tempCount++;
                            readObj[i]._name = data[tempCount];
                            tempCount++;
                            readObj[i]._cgpa = data[tempCount];
                            tempCount++;
                            readObj[i]._dep = data[tempCount];
                            tempCount++;
                            readObj[i]._uni = data[tempCount];
                            tempCount++;
                            readObj[i]._sem = data[tempCount];
                            tempCount++;
                            readObj[i]._atteandance = data[tempCount];
                            tempCount++;
                        }
                        for (int i = 0; i < totalStudents; i++)
                        {
                            if (id == readObj[i]._Id)
                            {
                                Console.Write(readObj[i]._Id + "\t");

                                Console.Write(readObj[i]._name + "\t");

                                Console.Write(readObj[i]._cgpa + "\t");

                                Console.Write(readObj[i]._dep + "\t\t");

                                Console.Write(readObj[i]._uni + "\t\t");

                                Console.Write(readObj[i]._sem + "\t\t");

                                Console.WriteLine("\n");
                            }
                        }
                    }
                    else if (opt == 2)
                    {
                        Console.Clear();
                        Console.WriteLine("Enter Name : ");
                        string   name = Console.ReadLine();
                        string[] data = File.ReadAllLines("Data.txt");

                        int       totalStudents = data.Length / 7;
                        int       tempO         = data.Length;
                        Student[] readObj       = new Student[totalStudents];

                        Console.WriteLine("ID \tName\tCGPA\tDepartment\tUniversity\tSemester\n\n\n");
                        int tempCount = 0;
                        for (int i = 0; i < totalStudents && tempCount != tempO; i++)
                        {
                            readObj[i]     = new Student();
                            readObj[i]._Id = data[tempCount];
                            tempCount++;
                            readObj[i]._name = data[tempCount];
                            tempCount++;
                            readObj[i]._cgpa = data[tempCount];
                            tempCount++;
                            readObj[i]._dep = data[tempCount];
                            tempCount++;
                            readObj[i]._uni = data[tempCount];
                            tempCount++;
                            readObj[i]._sem = data[tempCount];
                            tempCount++;
                            readObj[i]._atteandance = data[tempCount];
                            tempCount++;
                        }
                        for (int i = 0; i < totalStudents; i++)
                        {
                            if (name == readObj[i]._name)
                            {
                                Console.Write(readObj[i]._Id + "\t");

                                Console.Write(readObj[i]._name + "\t");

                                Console.Write(readObj[i]._cgpa + "\t");

                                Console.Write(readObj[i]._dep + "\t\t");

                                Console.Write(readObj[i]._uni + "\t\t");

                                Console.Write(readObj[i]._sem + "\t\t");

                                Console.WriteLine("\n");
                            }
                        }
                    }
                    else if (opt == 3)
                    {
                        string[] data = File.ReadAllLines("Data.txt");

                        int       totalStudents = data.Length / 7;
                        int       tempO         = data.Length;
                        Student[] readObj       = new Student[totalStudents];

                        Console.WriteLine("ID \tName\tCGPA\tDepartment\tUniversity\tSemester\tAttendance\n\n\n");
                        int tempCount = 0;
                        for (int i = 0; i < totalStudents && tempCount != tempO; i++)
                        {
                            Console.Write(data[tempCount] + "\t");
                            tempCount++;
                            Console.Write(data[tempCount] + "\t");
                            tempCount++;
                            Console.Write(data[tempCount] + "\t");
                            tempCount++;
                            Console.Write(data[tempCount] + "\t\t");
                            tempCount++;
                            Console.Write(data[tempCount] + "\t\t");
                            tempCount++;
                            Console.Write(data[tempCount] + "\t\t");
                            tempCount++;
                            Console.Write(data[tempCount] + "\t");
                            tempCount++;
                            Console.WriteLine("\n");
                        }
                    }
                }
                if (choice == 3)
                {
                }
                if (choice == 4)
                {
                }
                if (choice == 5)
                {
                }
                if (choice == 6)
                {
                    Console.Clear();

                    string[] data = File.ReadAllLines("Data.txt");

                    int       totalStudents = data.Length / 7;
                    int       tempO         = data.Length;
                    Student[] readObj       = new Student[totalStudents];

                    Console.WriteLine("ID \tName\tAttendance\n\n\n");
                    int tempCount = 0;
                    for (int i = 0; i < totalStudents && tempCount != tempO; i++)
                    {
                        readObj[i]     = new Student();
                        readObj[i]._Id = data[tempCount];
                        tempCount++;
                        readObj[i]._name = data[tempCount];
                        tempCount++;
                        readObj[i]._cgpa = data[tempCount];
                        tempCount++;
                        readObj[i]._dep = data[tempCount];
                        tempCount++;
                        readObj[i]._uni = data[tempCount];
                        tempCount++;
                        readObj[i]._sem = data[tempCount];
                        tempCount++;
                        readObj[i]._atteandance = data[tempCount];
                        tempCount++;
                    }
                    for (int i = 0; i < totalStudents; i++)
                    {
                        Console.Write(readObj[i]._Id + "\t");

                        Console.Write(readObj[i]._name + "\t");



                        if (readObj[i]._atteandance == "0")
                        {
                            Console.Write("Absent");
                        }
                        else
                        {
                            Console.Write("Present");
                        }
                        Console.WriteLine("\n");
                    }
                }
                Console.WriteLine("Press N to Quit or any other key to continue");
                ch = (Console.ReadLine());
                Console.ReadKey();
            }
        }
Exemplo n.º 15
0
Arquivo: Program.cs Projeto: PakVl/OOP
        static void Main(string[] args)
        {
            List<Student> Cheloveki = new List<Student>();

            Education SomeEd1 = (Education)1;
            Education SomeEd2 = (Education)2;
            Education SomeEd3 = (Education)3;
            Person Person1 = new Person("Александр", "Григорьев", new DateTime(1990, 10, 15));
            Student studP1 = new Student(Person1, SomeEd1, 32);
            Cheloveki.Add(studP1);
            bool work = true;
            while (work)
            {
                //Вывод меню
                Console.Clear();
                Console.WriteLine("1. Вывести список студентов");
                Console.WriteLine("2. Создать нового студента");
                Console.WriteLine("3. Добавить экзамен студенту");
                Console.WriteLine("4. Просмотр формы обучения студента");
                Console.WriteLine("5. Просмотр экзаменов студента");
                Console.WriteLine("6. Замер времени расчета массивов");
                Console.WriteLine("7. Выход");
                Console.WriteLine();
                Console.Write("Выбирите пункт: ");
                int Menu = Convert.ToInt32(Console.ReadLine());

                switch (Menu)
                {
                    case 1:
                        {
                            // Вывод всех студентов
                            Console.Clear();
                            if (Cheloveki.Count == 0)
                            {
                                Console.WriteLine("Список пуст");
                                Console.ReadKey();
                                break;
                            }
                            else
                            {
                                for (int i = 0; i < Cheloveki.Count; i++)
                                {
                                    Console.WriteLine(i + ": " + Cheloveki[i].ToShortString());
                                }
                                Console.WriteLine();
                                Console.WriteLine("Для перехода в меню нажмите любую клавишу");
                                Console.ReadKey();
                                break;
                            }
                        }
                    case 2:
                        {
                            //Создание нового студента
                            Console.Clear();

                            Console.Write("Введите имя: ");
                            string name = Console.ReadLine();
                            Console.Write("Введите Фамилию: ");
                            string surname = Console.ReadLine();

                            Console.Write("Год рождения: ");
                            int year = Convert.ToInt32(Console.ReadLine());
                            Console.Write("Месяц рождения: ");
                            int month = Convert.ToInt32(Console.ReadLine());
                            Console.Write("День рождения: ");
                            int day = Convert.ToInt32(Console.ReadLine());

                            Console.Clear();

                            Console.WriteLine("Формы обучения: ");
                            Console.WriteLine("1. Specialist");
                            Console.WriteLine("2. Вachelor");
                            Console.WriteLine("3. SecondEducation");

                            Console.Write("Выбирите форму обучения: ");
                            int formEd = Convert.ToInt32(Console.ReadLine());

                            Console.Clear();

                            Console.Write("Введите номер группы: ");
                            int nomGr = Convert.ToInt32(Console.ReadLine());

                            Console.Clear();

                            Cheloveki.Add(new Student(new Person(name, surname, new DateTime(year, month, day)), (Education)formEd, nomGr));

                            Console.WriteLine("Новый студент: " + Cheloveki[Cheloveki.Count - 1].ToString());
                            Console.WriteLine();
                            Console.ReadKey();
                            break;
                        }
                    case 3:
                        {
                            //Добавление экзамена студентам
                            List<Exam> ListEx = new List<Exam>();
                            Console.Clear();
                            for (int i = 0; i < Cheloveki.Count; i++)
                            {
                                Console.WriteLine(i + ": " + Cheloveki[i].ToShortString());
                            }
                            Console.WriteLine();
                            Console.Write("Выбирите студента: ");
                            int nomStud = Convert.ToInt32(Console.ReadLine());

                            Console.Clear();

                            Console.WriteLine(Cheloveki[nomStud].ToString());
                            Console.WriteLine();
                            while (true)
                            {
                                Console.WriteLine();
                                Console.Write("Добавить/выход ?: ");
                                if (Console.ReadLine() == "выход")
                                {
                                    break;
                                }
                                else
                                {
                                    Console.Write("Название предмета:");
                                    string nameIt = Console.ReadLine();
                                    Console.Write("Оценка:");
                                    int mark = Convert.ToInt32(Console.ReadLine());
                                    Console.Write("Год сдачи: ");
                                    int year = Convert.ToInt32(Console.ReadLine());
                                    Console.Write("Месяц сдачи: ");
                                    int month = Convert.ToInt32(Console.ReadLine());
                                    Console.Write("День сдачи: ");
                                    int day = Convert.ToInt32(Console.ReadLine());

                                    ListEx.Add(new Exam(nameIt, mark, new DateTime(year, month, day)));

                                    Cheloveki[nomStud].AddExams();
                                }
                            }
                            Cheloveki[nomStud].AddExams(ListEx.ToArray());
                            Console.WriteLine(Cheloveki[nomStud].ToString());
                            Console.WriteLine();
                            Console.ReadKey();
                            break;
                        }
                    case 4:
                        {
                            //Просмотр формы обучения
                            Console.Clear();
                            for (int i = 0; i < Cheloveki.Count; i++)
                            {
                                Console.WriteLine(i + ": " + Cheloveki[i].ToShortString());
                            }
                            Console.WriteLine();
                            Console.Write("Выбирите студента: ");
                            int nomStud = Convert.ToInt32(Console.ReadLine());

                            Console.Clear();

                            Console.WriteLine(Cheloveki[nomStud].ToString());
                            Console.WriteLine();

                            Console.WriteLine("Specialist: " + Cheloveki[nomStud][SomeEd1]);
                            Console.WriteLine("Вachelor: " + Cheloveki[nomStud][SomeEd2]);
                            Console.WriteLine("SecondEducation: " + Cheloveki[nomStud][SomeEd3]);
                            Console.WriteLine();
                            Console.WriteLine("Для перехода в меню нажмите любую клавишу");
                            Console.ReadKey();
                            break;
                        }
                    case 5:
                        {
                            //Просмотр списка экзаменов
                            Console.Clear();
                            for (int i = 0; i < Cheloveki.Count; i++)
                            {
                                Console.WriteLine(i + ": " + Cheloveki[i].ToShortString());
                            }
                            Console.WriteLine();
                            Console.Write("Выбирите студента: ");
                            int nomStud = Convert.ToInt32(Console.ReadLine());

                            Console.Clear();

                            Console.WriteLine(Cheloveki[nomStud].ToString());
                            Console.WriteLine();

                            for (int i = 0; i < Cheloveki[nomStud].FieldListExam.Length; i++)
                            {
                                Console.WriteLine(string.Format("Название:{0} Оценка:{1} Дата:{2} ", Cheloveki[nomStud].FieldListExam[i].NameItem, Cheloveki[nomStud].FieldListExam[i].Mark, Convert.ToString(Cheloveki[nomStud].FieldListExam[i].DateExam)));
                            }
                            Console.WriteLine();
                            Console.WriteLine("Для перехода в меню нажмите любую клавишу");
                            Console.ReadKey();
                            break;
                        }
                    case 6:
                        {
                            //Скорость отработки разных массивов
                            Console.Clear();
                            Console.Write("Введите размерность: ");
                            int n = Convert.ToInt32(Console.ReadLine());

                            MassTime t = new MassTime(n);

                            Console.WriteLine("Время работы: ");
                            Console.WriteLine("Одномерный массив: " + t.Timefirst());
                            Console.WriteLine("Двумерный массив: " + t.TimeRec());
                            Console.WriteLine("Двумерный ступеньчатый массив: " + t.TimedoSt());
                            Console.WriteLine();
                            Console.WriteLine("Для перехода в меню нажмите любую клавишу");
                            Console.ReadKey();
                            break;
                        }
                    case 7:
                        {
                            work = false;
                            break;
                        }
                }
            }
        }
Exemplo n.º 16
0
		public void AddStudent(Student student)
		{
			_students.Add(student);
		}
Exemplo n.º 17
0
 private void Copy()
 {
     student=  this.MemberwiseClone() as Student;
 }
Exemplo n.º 18
0
        private void RunDataTransportTest()
        {
            var nboot = new NinjectBootstrapper();
            nboot.Start();

            var svc = nboot.Get<IDataTransportService>();

            var student = new Student()
            {
                FirstName = "Clint",
                LastName = "Pearson",
            };

            var person = svc.MapLTR(student, new Person());

            var s = "";
        }
Exemplo n.º 19
0
Arquivo: Program.cs Projeto: PakVl/OOP
        static void Main(string[] args)
        {
            Person Chel1 = new Person();
            Person Chel2 = new Person();

            Console.WriteLine("Персоны: ");
            Console.WriteLine("1) " + Chel1.ToString());
            Console.WriteLine("2) " + Chel2.ToString());
            Console.ReadKey();
            Console.WriteLine();
            Console.WriteLine("Сравнения : ");
            Console.WriteLine(string.Format("Совпадение: {0}", Chel1.Equals((object)Chel2)));
            Console.WriteLine(string.Format("Хеш код 1 человека: {0} Хеш код 2 человека: {1} ", Chel1.GetHashCode(), Chel2.GetHashCode()));
            Console.WriteLine();
            Console.ReadKey();

            Student Stud1 = new Student();
            Stud1.FieldListExam.Add(new Exam("Алгебра", 5, new DateTime(2001, 10, 10)));
            Stud1.FieldListExam.Add(new Exam("Физика", 4, new DateTime(2001, 10, 11)));
            Stud1.FieldListExam.Add(new Exam("Магия", 3, new DateTime(2001, 10, 09)));
            Stud1.FieldListTest.Add(new Test("Базы данных", true));
            Stud1.FieldListTest.Add(new Test("Философия", false));
            Console.WriteLine("Студент: ");
            Console.WriteLine(Stud1.ToString());
            Console.ReadKey();
            Console.WriteLine();
            Console.WriteLine("Cвойство типа Person для объекта типа Student: ");
            Console.WriteLine(Convert.ToString(Stud1.FieldDateOfBirth));
            Console.ReadKey();
            Console.WriteLine();
            Student Stud2 = (Student)Stud1.DeepCopy();

            Stud1.FieldName = "Никита";
            Stud1.FieldGroup = 500;
            Console.WriteLine("Исходный: ");
            Console.WriteLine(Stud1.ToShortString());
            Console.WriteLine("Копия: ");
            Console.WriteLine(Stud2.ToShortString());
            Console.ReadKey();
            Console.WriteLine();

            Console.WriteLine("Отлов ошибки: ");
            try
            {
                Stud1.FieldGroup = 10;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            Console.ReadKey();
            Console.WriteLine();
            Stud1.List();

            Console.WriteLine("Итератор Объектов: ");
            foreach (object e in Stud1.GetStudExTest())
            {
                Console.WriteLine(Convert.ToString(e));
            }
            Console.ReadKey();
            Console.WriteLine();

            Console.WriteLine("Итератор условный: ");
            foreach (Exam e in Stud1.GetStudEx())
            {
                Console.WriteLine(Convert.ToString(e));
            }
            Console.ReadKey();
            Console.WriteLine();
        }
        static void Main(string[] args)
        {
            Student s1 = new Student();
            s1.Marks2 = 100;
            s1.CalculateNewPercent();

            Console.WriteLine("{0},{1},{2},{3}",s1.Name, s1.Marks1.ToString(), s1.Marks2.ToString(), s1.Percent.ToString());
            Student s2 = new Student("Swati", 0, 80);
            Console.WriteLine("{0},{1},{2},{3}", s2.Name, s2.Marks1.ToString(), s2.Marks2.ToString(), s2.Percent);
            Console.WriteLine();

            Console.ReadKey();
        }
Exemplo n.º 21
0
 private Student(Student s)
 {
     student = s;
 }