Keep the assignment histories, averages, tutoring details, and weekly reservations from your completed Grade Book 2.4. This lesson gives each class control over the collections and state that belong to it.
The estimates cover task work, including nested instructions, diagram interpretation, implementation, checks, and the explicitly assigned debugger work. Linked readings and videos and unplanned troubleshooting are excluded. These approximate planning guides may vary by student.
In MainWindow.xaml, update the window title from 2.4 to 2.5, retaining your last name. Keep .NET Framework 4.8. Update AssemblyVersion and AssemblyFileVersion in Properties/AssemblyInfo.cs to 2.5.0.0.
Keep the existing using System.Collections.Generic; directives in Course.cs and Instructor.cs.
| Class | Old field | New declaration and initializer |
|---|---|---|
Course |
Assignments |
private readonly List<Assignment> assignments = new List<Assignment>(); |
Instructor |
Assistants |
private readonly List<Instructor> assistants = new List<Instructor>(); |
Instructor |
NumberOfStudentsTutored |
private int numberOfStudentsTutored; |
Assignment |
Attempts |
private readonly Attempt[] attempts = new Attempt[3]; |
Assignment |
Submission |
private Attempt submission; |
TutoringSchedule |
Sessions |
private readonly Student[,] sessions = new Student[3, 5]; |
In the class diagram, - means private, + means public, and <readonly> means include the C# readonly keyword in the field declaration. Keep the classes themselves public.
Course.cs, add AddAssignment using the focused signature and activity diagramInstructor.cs, add AddAssistant using the focused signature and activity diagramCourse.cs, update GetAssignmentByType to use this.assignments for Count, indexing, and the returned matching entryKeep its existing null check, first-match break, and null result when no matching type exists.
Instructor.cs, change the foreach source in GetAssistantByKnowledgeLevel to this.assistantsKeep its first suitable assistant result, knowledge comparison, null check, and break.
Instructor.cs, update TutorStudent to increment this.numberOfStudentsTutored after a successful sessionKeep the existing guards, capped knowledge gain, and RequiredSessions decrement.
Assignment.cs, update Submit for the renamed private fieldsChange the stored history reference to this.attempts and the best passing submission field references to this.submission. The submission parameter still names the incoming attempt; keep the this prefix when referring to the field.
Assignment.cs, update FindAvailableAttempt for the renamed private fieldsUse this.attempts for Length and indexing. Keep the first empty index result and -1 when all three slots are occupied.
Assignment.cs, update GetBestAttempt for the renamed private fieldsRead this.attempts in the existing indexed loop. Keep its comparison and null result for an empty history.
Assignment.cs, update GetAttemptHistory for the renamed private fieldsRead this.attempts for the existing three-slot display. Keep Available, the letter grades, best accuracy, average accuracy, and line breaks.
Assignment.cs, update GetAverageAccuracy for the renamed private fieldsTraverse this.attempts. Keep the existing initialized locals, null filtering, count > 0 guard, and returned average.
TutoringSchedule.cs, update Attend to use this.sessions wherever it currently uses this.SessionsKeep the invalid-location and empty-cell guards, the two separate reservation-retained messages, the successful-session update, and the final feedback.
TutoringSchedule.cs, update Book to use this.sessions wherever it currently uses this.SessionsKeep the return codes, occupied-cell check, zero-required-sessions check, same-day search, and selected-cell assignment.
TutoringSchedule.cs, update Cancel to use this.sessions wherever it currently uses this.SessionsKeep both guards and clear only the selected occupied cell.
TutoringSchedule.cs, update CountBookings to use this.sessions wherever it currently uses this.SessionsKeep the foreach reference comparison and count only cells referring to the supplied non-null student.
TutoringSchedule.cs, update GetDisplay to use this.sessions wherever it currently uses this.SessionsKeep the period and weekday loops, row labels, [ ] and [X] cells, and line breaks.
TutoringSchedule.cs, update GetStudent to use this.sessions wherever it currently uses this.SessionsKeep the location check, null return for an invalid location, and selected-cell reference return.
TutoringSchedule.cs, update IsValidLocation to use this.sessions wherever it currently uses this.SessionsKeep the existing bounds expression and both GetLength dimensions.
Course.cs, add GetAssignmentHistory using the focused signature and activity diagramMainWindow.xaml.cs, replace the list traversal inside DisplayAssignmentHistories with the single display call in the activity diagramKeep its existing signature, private void DisplayAssignmentHistories(Course course). The two history event handlers already call this method and keep their current guards.
MainWindow.xaml.cs, update newBlackboardButton_Click using the diagramsUse the public operations shown in the controlled-access class diagram. Preserve the configured objects, values, and creation confirmation.
MainWindow.xaml.cs, update newCanvasButton_Click using the diagramsFollow the controlled-access class diagram and keep the existing Canvas objects, setup values, and schedule display refresh.
Build > Build Solution, open the Error List, and resolve any remaining references to the old public collection fieldsThe existing buttons and Click names stay in MainWindow.xaml. Keep the tutoring handlers, complete-tutoring feedback, attendance details, and their GetTutoringDetails calls.
Course.cs on if (assignment != null && !this.assignments.Contains(assignment)) inside AddAssignmentPress F5 to start debugging. Click New Blackboard to reach the first call before taking assignments or tutoring. The highlighted statement has not executed. Here this refers to the course, not the window.
Debug > Windows > Watch > Watch 1 while paused and inspect the starting registration stateAdd this.Name, assignment.Name, this.assignments.Count, and this.assignments[0] == assignment to Watch. At this first pause, the names are Web Design and Plan, and the count is 0. The indexed comparison cannot be evaluated until an entry exists; an unavailable expression is not a null reference.
F10 until this.assignments.Add(assignment); is highlighted, then press F10 to execute itConfirm this.assignments.Count is 1 and this.assignments[0] == assignment is true. The list entry and parameter refer to the same object; equal names alone would not prove that relationship.
F5 to finish creationConfirm Blackboard created. appears in the status area before clicking another control. Remove the Watch expressions. Do not call registration methods or change collection contents through Watch.
Open Course.AddAssignment and Instructor.AddAssistant. These are source traces, not UI tests: the creation buttons do not send these invalid requests. For each row, start with the stated object already registered where required. Follow short-circuit evaluation to show why the addition is skipped.
| Request | Condition result | Stored entries |
|---|---|---|
AddAssignment(null) |
false |
Unchanged |
AddAssignment with the same stored reference again |
false |
Unchanged |
AddAssistant(null) |
false |
Unchanged |
AddAssistant with the receiving instructor itself |
false |
Unchanged |
AddAssistant with the same stored reference again |
false |
Unchanged |
F5, click New Blackboard, then click Take midterm three times and Show Blackboard attempt historyDo not tutor or take another assignment first. Confirm HTML Exercises has three completed attempts. Its displayed best accuracy is 84.58% and average accuracy is 82.08%. These rounded displays represent calculated double values of approximately 84.575 and 82.075.
Plan and Website 1Confirm each still has three Available slots. Neither assignment was taken in this case.
Take midterm once moreConfirm The assignment or its instructor is unavailable, or all three attempts have been used. appears. Click Show Blackboard attempt history and confirm the three completed entries and both summary displays are unchanged. The preceding three successful attempts distinguish the full-history path in this case.
New Blackboard to reset Arthur, then click Tutor Arthur once without taking an assignment firstConfirm Tutoring session completed. appears with Sheldon as tutor, tutor knowledge 75.3, Arthur knowledge 70.5, and Required sessions remaining: 2. The calculated student knowledge is approximately 70.5.
New Canvas, select Monday in Day: and 1 in Period:, then click Book selected studentDo not tutor or take an assignment before booking. Confirm the Monday period 1 cell is [X] and the schedule displays Samantha reservations: 1.
AttendConfirm the feedback identifies Jeff with knowledge 95, Samantha with knowledge 92.8, and Required sessions remaining: 3. Samantha's calculated knowledge is approximately 92.8. Confirm the Monday period 1 cell becomes [ ] and the schedule displays Samantha reservations: 0.
New Canvas to reset Samantha, select Monday and period 1, click Book selected student, then click Complete Samantha tutoringConfirm Samantha completed 2 tutoring session(s)., No tutor has a higher knowledge level., Samantha knowledge 95, and Required sessions remaining: 2. Her calculated knowledge is approximately 95. Confirm the Monday period 1 cell remains [X] and the reservation count remains Samantha reservations: 1. Direct tutoring preserves the reservation.
AttendConfirm No tutor has a higher knowledge level. Reservation retained. appears. Samantha's displayed knowledge remains 95, required sessions remain 2, the selected cell stays [X], and the count remains Samantha reservations: 1.
Cancel reservationConfirm Reservation canceled., an empty Monday period 1 cell, and Samantha reservations: 0.
Cancel reservation again without booking another reservationConfirm No reservation was canceled. Select an occupied weekday and period. appears. The cell remains empty and the reservation count remains zero.
New Blackboard to reset Arthur, then click Tutor Arthur three times without taking an assignmentConfirm Arthur's displayed knowledge is 80.3 and Required sessions remaining: 0. His calculated knowledge is approximately 80.3.
Tutor Arthur once moreConfirm No tutoring sessions are required. appears. Arthur's displayed knowledge remains 80.3 and required sessions remain 0. This follows the zero-required-sessions guard, whereas the Canvas case retained two required sessions when no tutor could increase knowledge.
public methods the other classes can callBuild > Build Solution, open the Error List, and check the applicable StyleCop feedback