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

Create a C# console application for this question.Create class Course. Add two s

ID: 3777349 • Letter: C

Question

Create a C# console application for this question.Create class Course. Add two self-implemented propertiesCourseName and Instructor. Create a publicly accessible method DisplayInfo to display data stored in these two properties. Do not write any constructors. We will use an object initializer to initialize the properties when a Course object is instantiated.

     Write a test program to test this class. Create two instances of Courses: csc153 and csc152. Use object initializers to initialize CourseName and Instructor when these two courses are created. For csc153, initialize CourseName to Intro C# and Instructor to Leung. For csc152, initialize CourseName to SAS and Instructor to Orazem. Also write statements to invoke the DisplayInfo method for both courses.

    

     Your should get the following output:

Course: Intro C#    Instructor: Leung

Course: SAS    Instructor: Orazem

Explanation / Answer

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

namespace CallingClass
{
class Course

{
public string courseName;
public string instructor;

public void setCourseName(string value)
{
this.courseName = value;
}
public string getCourseName()
{
return this.courseName;
}

public void setInstructor(string name)
{
this.instructor = name;
}
public string getInstructor()
{
return this.instructor;
}
}
}

---------

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

namespace CallingClass
{
class Test
{

  

static void Main(string[] args)
{
Test test = new Test();
Course course = new Course();
course.setCourseName("Intro C#");
string name = course.getCourseName();
course.setInstructor("Leung");
string instructor = course.getInstructor();

Console.Write("name:{0} instructor:{1}",name,instructor );

Course course1 = new Course();
course1.setCourseName("SAS");
string name1 = course1.getCourseName();
course1.setInstructor("Orazem");
string instructor1 = course1.getInstructor();

Console.Write("name:{0} instructor:{1}", name1, instructor1);

Console.ReadKey();

}


}
}

output

name:Intro C# instructor:Leung
name:SAS instructor:Orazem