In 0.2, you worked with objects in the First Day application. In this assignment, you will use the same project to see how a program follows instructions and chooses between two paths.
You will add a small clothing decision, trace both paths with a breakpoint and F10, and then connect the decision to an It is raining checkbox. Most of the code is provided. Your job is to place it correctly, observe what the program does, and connect the activity diagram, C# code, and running application.
User Story
As a student preparing for the first day of class, I want the supplied application to choose between simple clothing options based on a condition so that I can see how program flow produces a decision.
Acceptance Criteria
Begin from a copy of your completed 0.2 First Day solution
Use the supplied activity diagram to predict the clothing decision
Add the supplied It is raining checkbox and Choose Clothing button
Trace both the true and false paths using a breakpoint and F10
Use the checkbox state to supply the Boolean used by the decision
Verify the activity diagram, C# code, and observed behavior describe the same decision
Submit the zipped solution through the Feedback System and submit the Feedback System URL to Canvas
Each code block shows only the code you need to add or change. Do not recopy code that is already working. Keep the existing Student, Breakfast, Backpack, Book, and Laptop code from 0.2.
Exact Casing Matters
Names such as rainCheckBox and ChooseClothingButton_Click must match exactly between XAML and C#.
1. Back Up and Open Your Existing First Day Solution
Your First Day solution was renamed to your last name in 0.2. Keep that working name for the rest of the sequence. At the beginning of each module, make a backup of the completed previous checkpoint, then continue working in the original student-named solution.
Step 1 — Make a checkpoint backup
One Working Name
The backup identifies the completed checkpoint. The working solution remains named for you, so later First Day assignments continue in the same project without repeatedly renaming the solution.
Step 2 — Verify the previous checkpoint
Build or run the solution before making the new 0.3 changes
Verify the major behavior you completed in 0.2 is still present
If the previous checkpoint is not working, correct that starting state before adding the new module work
A program normally follows instructions in sequence until it reaches a decision. At a decision, a true/false condition determines which path runs next.
Step 1 — Read the activity diagram
The activity diagram below represents the clothing decision you will add. The diamond is the decision point. During one run, the program follows only one of the two outgoing paths.
Clothing decision represented as a UML activity diagram.
Step 2 — Predict the path
If isRaining is true, predict which action will run
If isRaining is false, predict which action will run
Notice that both paths eventually reach Display recommendation
What to Notice
The diagram does not show C# syntax. It shows the logic: one condition, two possible paths, and one visible result.
The existing First Day window needs two small controls: a checkbox that can represent whether it is raining and a button that runs the clothing decision. The decision will not use the checkbox immediately; first you will trace the logic with a fixed Boolean value.
Step 1 — Open MainWindow.xaml
In Solution Explorer, open FirstDayScenario/MainWindow.xaml
Locate the existing StackPanel that contains the New Student, Have Breakfast, and Fill Backpack buttons
Add the new controls inside the existing StackPanel, directly after Fill Backpack.
Step 2 — Make room for the new controls
Change the Window height so the additional controls and output area fit comfortably.
Confirm that It is raining and Choose Clothing appear below the existing three buttons
The application may not yet respond correctly when you click Choose Clothing because the C# event handler has not been added
The window should contain the existing controls plus the new checkbox and button.Go to top
4. Add and Trace the Decision
Now you will add the event handler that runs when Choose Clothing is clicked. The first version deliberately uses a fixed true value. This makes the program path predictable while you learn to trace it.
Step 1 — Add the supplied event handler
Open FirstDayScenario/MainWindow.xaml.cs
Scroll to the bottom of the MainWindow class
Place the new event handler after FillBackpackButton_Click, but before the closing brace of the MainWindow class
The new handler belongs inside MainWindow but outside the existing event handlers.
MainWindow.xaml.cs — add this event handler
/// <summary>
/// Chooses clothing based on whether it is raining.
/// </summary>
/// <param name="sender">The object that initiated the event.</param>
/// <param name="e">The event arguments for the event.</param>
private void ChooseClothingButton_Click(object sender, RoutedEventArgs e)
{
bool isRaining = true;
if (isRaining)
{
this.textOutput.Text = "Wear a rain jacket.";
}
else
{
this.textOutput.Text = "Wear a hoodie.";
}
}
Step 2 — Trace the true path
Set a breakpoint on if (isRaining)
Press F5 to start debugging
Click Choose Clothing
When Visual Studio pauses, inspect isRaining
Before stepping, predict which branch will execute
Press F10 to step over the decision and follow the statements one at a time
Continue until the recommendation appears in the output area
At the breakpoint, verify the Boolean value before following the true branch.
Check Your Work
isRaining should be true at the breakpoint
The program should follow the first branch
The output should display Wear a rain jacket.
The observed path should match the true path in the activity diagram
Model → Code → Behavior
The activity diagram's decision becomes the C# if. The true path becomes the first code block. The visible text is the runtime evidence that the branch executed.
The decision structure does not need to change to produce a different result. Change only the Boolean value and observe how the same if/else selects the other path.
Step 1 — Change one value
Change this line:
Current line
bool isRaining = true;
to:
Temporary line for tracing the false path
bool isRaining = false;
Step 2 — Predict, run, and trace
Before running, predict the displayed recommendation
Use the same breakpoint on if (isRaining)
Run the application and click Choose Clothing
Verify isRaining is now false
Use F10 and observe the program skip the true block and enter the else block
The same decision now follows the false path because the Boolean state changed.
Check Your Work
The output should display Wear a hoodie.
Only the Boolean value changed; the decision structure stayed the same
The observed path should match the false path in the activity diagram
When the checkbox is checked, this expression produces true. When it is not checked, it produces false. The rest of the decision can keep using the same Boolean variable.
Step 2 — Test the unchecked state
Leave It is raining unchecked
Run to the breakpoint on if (isRaining)
Verify isRaining is false
Use F10 to verify the hoodie path runs
Step 3 — Test the checked state
Stop and restart the application if needed
Check It is raining
Click Choose Clothing
At the breakpoint, verify isRaining is true
Use F10 to verify the rain-jacket path runs
The checkbox is now the source of the Boolean used by the clothing decision.
Final Activity Diagram
The complete 0.3 flow now begins with user-interface state, converts that state into a Boolean, and uses the same decision you already traced.
Completed 0.3 activity flow from checkbox state to clothing recommendation.
Check Your Work
Unchecked checkbox → isRaining is false → hoodie
Checked checkbox → isRaining is true → rain jacket
The activity diagram, C# decision, and running application all describe the same two-path flow
Key Takeaway
You have connected user-interface state → Boolean value → decision → program path → visible result.
Review the Feedback System results and correct any in-scope issues if required
Resubmit a corrected ZIP when needed
Step 4 — Submit the Feedback System URL to Canvas
After the required Feedback System submission is ready, copy its URL
Open the correct 0.3 First Day Assignment in Canvas
Submit the Feedback System URL as your Canvas submission
Checkpoint Summary
You started from your completed 0.2 project, represented a two-path clothing decision with a UML activity diagram, traced both Boolean paths in C#, and connected a WPF checkbox to the Boolean used by the decision.