Question: I am debugging the following in C# and cant find the cause of my errors, I am new and still rather confused. Can someone help?
I am debugging the following in C# and cant find the cause of my errors, I am new and still rather confused. Can someone help?
// Creates a HomeworkAssignment class // instantiates two objects // and prompts the user for infromation about two courses using static System.Console; class FixedDebugNine1 { public static void Main() { HomeworkAssignment course1 = new HomeworkAssignment(); HomeworkAssignment course2 = new HomeworkAssignment(); string entryString; int exercises;
// Get info for first class Write("What class do you have homework for? "); entryString = ReadLine(); course1.ClassName = entryString; Write("How many exercises must you complete? "); entryString = ReadLine(); int.TryParse (entryString, exercises); exercises = course1.NumberOfExercises;
// Get info for another class Write("What class do you have homework for? "); entryString = ReadLine(); course2.ClassName = entryString; Write("How many exercises must you complete? "); entryString = ReadLine(); char.TryParse(entryString, exercises); course2.NumberOfExercises = exercises;
WriteLine("You have {0} minutes of homework for {1}", course1.TimeToComplete, course1.ClassName); WriteLine("and {0} more minutes for {1}", course2.TimeToComplete, course2.ClassName); } } class HomeworkAssignment { private int numberOfExercises; private int timeToComplete; // 10 minutes to complete each exercise private const int TIME_PER_EXERCISE = 10; public string ClassName {get; set;} public int NumberOfExercises
{ get { return numberOfExercises; } set { numberOfExercises = value; CalcCompletionTime(); } } public int TimeToComplete { get { return TimeToComplete; } } private void CalcCompletionTime() { timeToComplete = numberOfExercises * TIME_PER_EXERCISE; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
