Exemplo n.º 1
0
        public void RegisterStudents()
        {
            Console.WriteLine($"Showing object creation and maipulation of Salutation property.\r\n {_sectionBreak} \r\n");

            Person person = new Person("Brian", "Lee");

            person.Salutation = Salutation.Mr;

            //This is manipulating a static variable
            Console.WriteLine(person.Salutation);

            person.Salutation = Salutation.Mrs;
            Console.WriteLine(person.Salutation);

            person.Salutation = Salutation.SuperCool;
            Console.WriteLine(person.Salutation);

            Console.WriteLine(_sectionBreak + Environment.NewLine);

            Console.WriteLine("Now viewing children objects created from abstract parent class.\r\n " +
                              "Also use of interface reference type. Press any key to continue.");
            Console.WriteLine(_sectionBreak);
            Console.ReadKey();


            //creating a student object using parent reference variable
            Person underGradstudent1 = new UndergraduateStudent(12345);
            //ShowAdvisor(underGradstudent1); //this is a no-go
            //notice only the Person properties and methods are avaliable

            Student underGradstudent2 = new UndergraduateStudent(11111);

            underGradstudent2.Salutation = Salutation.SuperCool;
            Console.WriteLine($"Student's full name: {underGradstudent2.Salutation} {underGradstudent2.FirstName} {underGradstudent2.LastName}");
            //GetStudentsBehavior(underGradstudent2);  //--that's a no-go, Student does not implement IStudentBestPractices
            ShowAdvisor(underGradstudent2);
            Console.WriteLine(_sectionBreak);

            UndergraduateStudent underGradstudent3 = new UndergraduateStudent(12256);

            underGradstudent3.Salutation = Salutation.SuperCool;
            Console.WriteLine($"Student's full name: {underGradstudent3.Salutation} {underGradstudent3.FirstName} {underGradstudent3.LastName}");
            //Console.WriteLine($"Student's behavior: \r\n {underGradstudent3.Study()} \r\n {underGradstudent3.Rest()}");
            GetStudentsBehavior(underGradstudent3);
            ShowAdvisor(underGradstudent3);
            Console.WriteLine(_sectionBreak);

            GraduateStudent graduateStudent1 = new GraduateStudent(5555);

            graduateStudent1.Salutation = Salutation.SuperCool;
            Console.WriteLine($"Student's full name: {graduateStudent1.Salutation} {graduateStudent1.FirstName} {graduateStudent1.LastName}");
            GetStudentsBehavior(graduateStudent1);
            ShowAdvisor(graduateStudent1);
            Console.WriteLine(_sectionBreak);


            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // initial access attempt
            Person Student = new Person
            {
                firstName = "John",
                lastName  = "Doe"
            };

            // after fixing access permissions
            Debug.WriteLine(Student.getName());

            // using the constructor
            Person Teacher = new Person();
            Person Manager = new Person("Jane");

            // passing by value
            int testVar1 = 3;
            int result1  = ModifyPrimitiveArgument(testVar1);

            Debug.WriteLine(testVar1 + " " + result1);

            // passing by reference
            Person testVar2 = new Person("Doe");
            Person result2  = ModifyObjectArgument(testVar2);

            Debug.WriteLine(testVar2.lastName + " " + result2.lastName);

            // using a child class
            Student Student1 = new Student();

            // using a child class
            Student Student2 = new Student();

            // interfaces
            GraduateStudent Grad = new GraduateStudent();

            Debug.WriteLine(Grad.Study());
        }