Give other objects controlled access to Grade Book information. Convert the public fields from your completed 2.6 project to properties, keep the data in private backing fields, and calculate probation from the number of tutoring sessions still required.
Use your last name in the window title. Use 2.7.0.0 for AssemblyVersion and AssemblyFileVersion. Keep .NET Framework 4.8 and the existing controls and handlers.
A property is used by its name, like a field, but its accessor contains executable code. A getter returns a value. A setter receives an assigned value in its implicit value parameter. A private backing field stores the data. A property with only a getter cannot be assigned by outside code.
public double Accuracy
{
get
{
return this.accuracy;
}
}Accuracy is the public property; accuracy is the private field. The constructor assigns the backing field. Existing callers continue reading attempt.Accuracy. There are no method-call parentheses after a property name.
In the diagrams, <get;> means a getter only and <get; set;> means both accessors. Keep a backing field's existing readonly modifier where shown. Do not make the mutable fields Attempt.score, Student.knowledgeLevel, Student.requiredSessions, or Instructor.certificationExam readonly. The separate Instructor.knowledgeLevel field remains readonly. Complete the conversion tasks before building; a class can temporarily fail to compile while its old field references are being renamed.
Keep attempts and submission private. Existing methods continue to control attempts and accepted submissions.
Keep the parameter names and argument order shown in the diagram. Keep the three-slot attempt array initialization.
Keep the accuracy calculation and Attempt construction unchanged.
Keep the slot displays, best accuracy, and average accuracy.
Keep the existing null check and grading delegation.
The score remains mutable inside Attempt. A read-only property prevents callers from setting the score directly; it does not prevent Attempt.Grade from updating the backing field.
Keep the invalid-value check and the existing A, B, C, and F thresholds.
Keep the existing positive-points and accuracy-range checks and the unrounded score calculation.
Keep the assignments list private and retain AddAssignment and GetAssignmentHistory.
Keep the assignments-list initialization.
Keep GetTutor public: the tutoring handlers use it to identify the selected instructor before the session begins. Keep the assistant search and teacher fallback.
Keep the existing arguments and create new TutoringSchedule() in this.schedule. The CurrentStudent and PrimaryInstructor properties must return the same references that were passed to the constructor.
Keep the existing assistants list and numberOfStudentsTutored field private.
Keep the assistants-list initialization.
Continue to update the student's required sessions through its public RequiredSessions property. Keep the knowledge-gain limit, the positive-session check, and the count increment.
The get and set blocks are siblings inside one property. A setter has no explicit parameter list: C# automatically supplies value with the property's type, Attempt here. Complete the setter's condition and assignment from the activity diagram.
public Attempt CertificationExam
{
get
{
return this.certificationExam;
}
set
{
// Implement the validation and assignment from the activity diagram.
}
}The getter returns the stored field. Use the activity diagram for the setter. A non-null assignment replaces the reference; a null assignment leaves the current reference unchanged.
The existing creation handlers still assign their newly constructed certification attempts through this property.
Keep course, id, and name readonly. Keep knowledgeLevel mutable because Learn updates it. The next tasks replace the remaining RequiredSessions and IsOnProbation fields.
Keep the signature unchanged. Required sessions will still be assigned after construction by the creation handlers.
The getter returns the stored field. Build the setter from the activity diagram. Accept values from 0 through 10 inclusive. Reject an out-of-range assignment by leaving the field unchanged.
Return the result of checking whether this.requiredSessions is greater than zero. Do not add a second field for probation.
Keep the course/instructor guards, assignment search, available-slot check, submission, and learning call.
Keep sessionsBefore, the positive-session check, and the comparison that reports whether tutoring reduced RequiredSessions.
Keep the positive-gain condition and the maximum knowledge level of 100.
Keep the student/teacher guards, tutor selection, and TutorStudent call shown in the activity diagram. The Student property now calculates probation when read.
Use the Student property diagram to determine which assignments remain valid. Preserve the existing setup values, object relationships, and creation feedback.
Compare the focused diagrams with your code. Keep external reads in their existing PascalCase form; only code inside the class uses that class's lower-case backing fields. Keep required-session changes through RequiredSessions and the certification assignment through CertificationExam.
Start debugging and click New Canvas. At the MainWindow breakpoint, open Watch 1 and add the expressions below. They are not in scope yet. Disable this MainWindow breakpoint before continuing to the setter.
| Expression | What to observe |
|---|---|
| value | Unavailable outside the setter; the value being assigned inside it |
| this.requiredSessions | The Student backing field while stopped inside Student |
| this.RequiredSessions | The getter returns the same stored number |
| this.IsOnProbation | Calculated from the stored number |
Unavailable means an expression is outside the current scope; it does not mean its value is null. Before the setter is entered, value is unavailable. Inside Student, this is the student, rather than the MainWindow that initiated creation.
The highlighted condition has not executed. Step with F10 through the condition and field assignment until the assignment has executed. Confirm RequiredSessions is 4 and IsOnProbation is true.
At the next setter entry, value is 3 and the stored requirement is still 4. Step over the accepted assignment and confirm the stored requirement becomes 3. Disable the breakpoint and press F5 to let the handler display its full message.
These are source traces, not additional UI inputs. Each row begins with a stored requiredSessions value of 4.
| Assigned value | Stored value afterward | IsOnProbation afterward |
|---|---|---|
| -1 | 4 | true |
| 0 | 0 | false |
| 10 | 10 | true |
| 11 | 4 | true |
The stored reference is retained. With a non-null assigned Attempt reference, the stored reference becomes that same object. The setter does not instantiate a copy.
Arthur begins at knowledge level 65.5 with 3 required sessions. The three successful sessions leave him at 80.3 with 0 required sessions. From the getter condition, infer that IsOnProbation now returns false; this status is not printed in the feedback. Another Tutor Arthur click reports No tutoring sessions are required. and retains the tutor/student details.
Samantha completes 2 sessions, reaches knowledge level 95, and still requires 2 sessions. No tutor has higher knowledge, so processing stops. From its getter condition, IsOnProbation remains true; the feedback does not print that property. The outcome and tutor/student details still appear.
The selected reservation remains occupied because no tutor can add knowledge. The message includes No tutor has a higher knowledge level. Reservation retained. and the tutor/student details. The displayed reservation count stays 1.
The attempt accuracy is 79.575%, its letter grade is C, and the history rounds its displayed accuracy to 79.58%. Best and average accuracy both display 79.58%. Arthur's knowledge increases to 70.5. This confirms that property access preserves the calculation, grading, history, and learning behavior.
The first three attempts occupy the existing three slots. The fourth click reports the existing unavailable/three-attempt-limit message; no fourth attempt is added.