This is a C# program that\'s needed. 1. Create an abstract class \"Student.cs\".
ID: 3848745 • Letter: T
Question
This is a C# program that's needed.
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.
Student
FirstName
LastName
StudentID
abstract ImportantThing()
Student
FirstName
LastName
StudentID
abstract ImportantThing()
Explanation / Answer
abstract class Student
{
public string firstName;
public string lastName;
public string studentID;
protected Student(string firstname, string lastname, string studentid)
{
firstName=firstname;
lastName=lastname;
studentID=studentid;
}
public string getFirstName {get { return firstName;}}
public string getLastName {get { return lastName;}}
public string getStudentID {get { return studentID;}}
public abstract string ImportantThing();
}
public interface IMathClass
{
string Math();
}
class ElementarySchoolStudent : Student,IMathClass {
public ElementarySchoolStudent() : Student(string firstname, string lastname, string studentid) {}
public override string ImportantThing() { return "Farm field trip!"; }
public override string Math() { return "Basic Math."; }
public override void toString() {}
}
class MiddleSchoolStudent : Student,IMathClass {
public MiddleSchoolStudent() : Student(string firstname, string lastname, string studentid) {}
public override string ImportantThing() { return "Summer Camp!"; }
public override string Math() { return "Geometry."; }
public override void toString() {}
}
class HighSchoolStudent : Student,IMathClass {
public HighSchoolStudent() : Student(string firstname, string lastname, string studentid) {}
public override string ImportantThing() { return "SAT exam."; }
public override string Math() { return "Basic Algebra."; }
public override void toString() {}
}
class CollegeStudent : Student,IMathClass {
public CollegeStudent() : Student(string firstname, string lastname, string studentid) {}
public override string ImportantThing() { return "Major."; }
public override string Math() { return "Advanced Algebra."; }
public override void toString() {}
}
class Program
{
static void Main(string[] args){
Student[] student = new Student[4];
student[0]= new ElementarySchoolStudent("roy","greg","12345");
student[1]= new MiddleSchoolStudent("tony","mack","4567");
student[2]= new HighSchoolStudent("ashish","maa","9876");
student[3]= new CollegeStudent("jhon","cena","9023");
for (i=0; i<=3; i=i+1)
{
Console.WriteLine(student[i].firstName.toString());
Console.WriteLine(student[i].lastName.toString());
Console.WriteLine(student[i].studentID.toString());
Console.WriteLine(student[i].ImportantThing().toString());
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.