Question: Using C# and including comments to explain implementation Create a Console Application Project called GradeBook that includes the following two classes: ****GradeBook.cs****** // GradeBook class
Using C# and including comments to explain implementation
Create a Console Application Project called GradeBook that includes the following two classes:
****GradeBook.cs******
// GradeBook class with an auto-implemented property. using System; using static System.Console;
public class GradeBook { // auto-implemented property CourseName implicitly creates // an instance variable for this GradeBook's course name public string CourseName { get; set; }
// display a welcome message to the GradeBook user public void DisplayMessage() { // use auto-implemented property CourseName to get the // name of the course that this GradeBook represents Console.WriteLine("Welcome to the grade book for {0}!", CourseName); // display property CourseName Console.ReadLine(); } // end method DisplayMessage } // end class GradeBook
*******************************************************************
***********GradeBookTest.cs*************
// Creates and manipulate a GradeBook object. using System; using static System.Console;
public class GradeBookTest { // Main method begins program execution public static void Main( string [] args ) { // create a GradeBook object and assign it to myGradeBook GradeBook myGradeBook = new GradeBook();
// display initial value of CourseName Console.WriteLine("Initial course name is: '{0}' ", myGradeBook.CourseName);
// prompt for and read course name Console.WriteLine("Please enter the course name:"); myGradeBook.CourseName = Console.ReadLine(); // set CourseName Console.WriteLine(); // output a blank line
// display welcome message myGradeBook.DisplayMessage(); } // end Main } // end class GradeBookTest
***********************************************************************
Modify the two GradeBook classes as follows:
- Include a second string auto-implented property that represents the name of the courses instructor. - Modify the constructor to specify two parametersone for the course name and one for the instructors name. - Modify the DisplayMessage method such that it first outputs the welcome message and course name, then outputs, This course is presented by: , followed by the instructors name. -Reference a constructor not provided in the initial code -Maybe should just provide it -Then initial test program must provide a course name parameter -Remove readline from the display message method -Use a regular property with explicit get and set? allow students to use an auto-implementation if they want? Or require that they use it?
Testing program - Modify initialization of course name and/or course instructor?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
