Esempio n. 1
0
 public Student(Person person, Person.Education education, int groupNumber)
     : base(person.FirstName, person.LastName, person.DOB)
 {
     _education = education;
     _groupNumber = groupNumber;
     _exams = new ArrayList();
     _tests = new ArrayList();
 }
Esempio n. 2
0
 public virtual object DeepCopy()
 {
     Person person = new Person();
     person._dob = this._dob;
     person._firstName = this._firstName;
     person._lastName = this._lastName;
     person.IsDOBChangeble = this.IsDOBChangeble;
     return person;
 }
Esempio n. 3
0
 public bool this[Person.Education education]
 {
     get
     {
         return education == _education;
     }
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            Person person1 = new Person("Keith", "Ebner", DateTime.Parse("1978-05-11"));
            Person person2 = new Person("Keith", "Ebner", DateTime.Parse("1978-05-11"));

            if (object.ReferenceEquals(person1, person2))
            {
                Console.WriteLine("Reference Equals");
            }
            else
            {
                Console.WriteLine("Reference is not Equals");
            }

            if (person1 == person2)
            {
                Console.WriteLine("Objects are equal");
                Console.WriteLine("Person1 hash code: " + person1.GetHashCode());
                Console.WriteLine("Person2 hash code: " + person2.GetHashCode());
            }
            else
            {
                Console.WriteLine("Objects are not equals");
            }

            Console.WriteLine();

            Student student = new Student(new Person("Keith", "Ebner", DateTime.Parse("1978-05-11")), Person.Education.Specialist, 4);
            student.AddExams(new Person.Exam("Math", 4, DateTime.Parse("2013-12-12")), new Person.Exam("History", 5, DateTime.Parse("2013-11-12")));
            student.AddTests(new Test("History", true), new Test("MySubj", false));

            Console.WriteLine(student.ToString());

            Console.WriteLine(student.Person.ToString());

            Student student1 = (Student)student.DeepCopy();

            student.FirstName = "asdafasd";

            Console.WriteLine();

            Console.WriteLine(student.ToString());

            Console.WriteLine();

            Console.WriteLine(student1.ToString());

            Console.WriteLine();

            try
            {
                student.GroupNumber = 1;
            }
            catch (FormatException e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine();

            StudentEnumerator studentEnumerator = new StudentEnumerator(student);

            foreach (var item in studentEnumerator)
            {
                Console.WriteLine(item);
            }

            Console.WriteLine();

            foreach (var item in student.Iterator(3))
            {
                Console.WriteLine(item);
            }

            Console.WriteLine();

            foreach (var item in student.IteratorPassedTests())
            {
                Console.WriteLine(item);
            }
        }