Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Create an abstract class “Student.cs”. Read page 329. 3 public string data me

ID: 3848908 • Letter: 1

Question

1. Create an abstract class “Student.cs”. Read page 329. 3 public string data members: firstName, lastName, studentID.
Create a constructor to initialize each data member value. Create read-only property for each data member. Read Page 329. Create an abstract method “ImportantThing()”, returns string.
2. Create an Interface “IMathClass.cs”. Declare a method “Math()”, returns string.
3. Create classes “ElementarySchoolStudent.cs”, “MiddleSchoolStudent.cs”, “HighSchoolStudent.cs”, “CollegeStudent.cs”, inherit “Student.cs” and “IMathClass.cs” to each of them.
ElementarySchoolStudent.cs
o Constructor with three parameters for firstName, lastName, studentID. Read page 301.
o ImportantThing() returns "Farm field trip!".
o Math() returns "Basic Math."
o Override toString().
MiddleSchoolStudent.cs
o Constructor with three parameters for firstName, lastName, studentID.
o ImportantThing() returns "Summer Camp!".
o Math() returns "Geometry."
o Override toString().
HighSchoolStudent.cs
o Constructor with three parameters for firstName, lastName, studentID.
o ImportantThing() returns "SAT exam.".
o Math() returns "Basic Algebra."
o Override toString().
CollegeStudent.cs
o Constructor with three parameters for firstName, lastName, studentID.
o ImportantThing() returns "Major.".
o Math() returns "Advanced Algebra.".
o Override toString().
4. In “Program.cs”, in method “main()”, create an “Student” type array with size of 4. Read page 321.
First element is ElementarySchoolStudent object with any first name, last name, student ID for constructor.
Second element is MiddleSchoolStudent object with any first name, last name, student ID for constructor.
Third element is HighSchoolStudent object with any first name, last name, student ID for constructor.
Fourth element is CollegeStudent object with any first name, last name, student ID for constructor. for loop to go through array, call .toString for each object.

My name is Sanuel Clark, Ian an Elementary school student, will have an exciting Farm field trip!, !Will ear My name is David Hunt, I an a niddle school student,l will have a Summer Camp!, I will learn Geonetry, My name is Mary Anderson, I an high school student, I will take SAT exam, I learn Basic Algebra My name is Tin Russell, I an a college student, have a Major, I learn Advanced Algebra. Press any key to continue

Explanation / Answer

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Exam3 {
    class Program {
        static void Main(string[] args) {
            Student[] students = new Student[4];
            students[0] = new ElementarySchoolStudent("John", "Smith", "0001");
            students[1] = new MiddleSchoolStudent("Leroy", "Jenkins", "0002");
            students[2] = new HighSchoolStudent("Jerry", "Seinfeld", "0003");
            students[3] = new CollegeStudent("Jake", "Gillianhall", "0004");

            foreach (Student student in students) {
                Console.WriteLine(student.ToString());
            }
        }
    }
}

CollegeStudent.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Exam3 {
    class CollegeStudent : Student {
        public CollegeStudent(string first, string last, string id)
            : base(first, last, id) {

        }

        public override string ImportantThings() {
            return "Major.";
        }

        public override string Math() {
            return "Advanced Algebra.";
        }

        public override string ToString() {
            return $"My name is {firstName}, " +
                $"I am a college student. " +
                $"I have a {ImportantThings()}, " +
                $"I learn {Math()}. ";
        }
    }
}


ElementarySchoolStudent.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Exam3 {
    class ElementarySchoolStudent : Student {
        public ElementarySchoolStudent(string first, string last, string id)
            : base (first, last, id) {
          
        }

        public override string ImportantThings() {
            return "Farm Field Trip";
        }

        public override string Math() {
            return "Basic Math";
        }

        public override string ToString() {
            return $"My name is {firstName}, " +
                $"I am a an Elementary school student. " +
                $"I will have an exciting {ImportantThings()}, " +
                $"I will learn {Math()}. ";
        }
    }
}


HighSchoolStudent.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Exam3 {
    class HighSchoolStudent : Student {
        public HighSchoolStudent(string first, string last, string id)
            :base(first, last, id) {

        }

        public override string ImportantThings() {
            return "SAT Exam.";
        }

        public override string Math() {
            return "Basic Algebra.";
        }

        public override string ToString() {
            return $"My name is {firstName}, " +
                $"I am a high school student. " +
                $"I will take {ImportantThings()}, " +
                $"I learn {Math()}. ";
        }
    }
}


IMathClass.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Exam3 {
    class IMathClass {
        public virtual string Math() {
            return "";
        }
    }
}


MiddleSchoolStudent.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Exam3 {
    class MiddleSchoolStudent : Student {
        public MiddleSchoolStudent(string first, string last, string id)
            :base(first, last, id) {
          
        }

        public override string ImportantThings() {
            return "Summer Camp!";
        }

        public override string Math() {
            return "Basic Algrbra.";
        }

        public override string ToString() {
            return $"My name is {firstName}, " +
                $"I am a middle school student. " +
                $"I will have {ImportantThings()}, " +
                $"I will learn {Math()}. ";
        }
    }
}

Student.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Exam3 {
    class Student : IMathClass {
        public string firstName, lastName, studentID;
        public Student(string first, string last, string Id) {
            firstName = first;
            lastName = last;
            studentID = Id;
        }

        public virtual string ImportantThings() {
            return "";
        }
      
    }
}