0.3 First Day Assignment

Overview

Program Flow and Decisions

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

Task List

  1. Get Started From Your 0.2 Solution
  2. Predict the Clothing Decision
  3. Add the Clothing Controls
  4. Add and Trace the Decision
  5. Trace the Other Path
  6. Connect the Checkbox to the Boolean
  7. Final Check and Submit
Before You Begin

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. 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

    1. Build or run the solution before making the new 0.3 changes
    2. Verify the major behavior you completed in 0.2 is still present
    3. If the previous checkpoint is not working, correct that starting state before adding the new module work
    Go to top
  2. 2. Predict the Clothing Decision

    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.

    Activity diagram: read isRaining; if true choose a rain jacket, otherwise choose a hoodie; then display the recommendation.
    Clothing decision represented as a UML activity diagram.

    Step 2 — Predict the path

    1. If isRaining is true, predict which action will run
    2. If isRaining is false, predict which action will run
    3. 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.

    Go to top
  3. 3. Add the Clothing Controls

    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

    1. In Solution Explorer, open FirstDayScenario/MainWindow.xaml
    2. Locate the existing StackPanel that contains the New Student, Have Breakfast, and Fill Backpack buttons
    Screenshot placeholder showing MainWindow.xaml and the insertion point below the existing Fill Backpack button
    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.

    MainWindow.xaml — update the Window height
    <Window x:Class="FirstDayScenario.MainWindow"
            ...
            Title="MainWindow" Height="520" Width="400">

    Change the existing StackPanel and add the two supplied controls. Keep one physical XAML element per line.

    MainWindow.xaml — replace the current StackPanel with this version
    <StackPanel HorizontalAlignment="Center" Height="190" Margin="0, 10, 0, 0" VerticalAlignment="Top" Width="375">
        <Button x:Name="newStudentButton" Content="New Student" Width="300" Margin="5" Click="NewStudentButton_Click" />
        <Button x:Name="haveBreakfastButton" Content="Have Breakfast" Width="300" Margin="5" Click="HaveBreakfastButton_Click" />
        <Button x:Name="fillBackpackButton" Content="Fill Backpack" Width="300" Margin="5" Click="FillBackpackButton_Click" />
        <CheckBox x:Name="rainCheckBox" Content="It is raining" Width="300" Margin="5" />
        <Button x:Name="chooseClothingButton" Content="Choose Clothing" Width="300" Margin="5" Click="ChooseClothingButton_Click" />
    </StackPanel>

    Move the output area lower and make it slightly taller.

    MainWindow.xaml — replace the existing textOutput TextBox with this line
    <TextBox x:Name="textOutput" HorizontalAlignment="Center" Height="220" Margin="0,230,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="300" BorderThickness="3" BorderBrush="#FFB3B3B4" />

    Check Your Work

    1. Build the solution
    2. Run the application
    3. Confirm that It is raining and Choose Clothing appear below the existing three buttons
    4. The application may not yet respond correctly when you click Choose Clothing because the C# event handler has not been added
    Screenshot placeholder showing the First Day application with the new rain checkbox and Choose Clothing button
    The window should contain the existing controls plus the new checkbox and button.
    Go to top
  4. 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

    1. Open FirstDayScenario/MainWindow.xaml.cs
    2. Scroll to the bottom of the MainWindow class
    3. Place the new event handler after FillBackpackButton_Click, but before the closing brace of the MainWindow class
    Screenshot placeholder showing where the new ChooseClothingButton_Click handler belongs in MainWindow.xaml.cs
    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

    1. Set a breakpoint on if (isRaining)
    2. Press F5 to start debugging
    3. Click Choose Clothing
    4. When Visual Studio pauses, inspect isRaining
    5. Before stepping, predict which branch will execute
    6. Press F10 to step over the decision and follow the statements one at a time
    7. Continue until the recommendation appears in the output area
    Screenshot placeholder showing Visual Studio paused at the clothing decision with isRaining equal to true
    At the breakpoint, verify the Boolean value before following the true branch.

    Check Your Work

    1. isRaining should be true at the breakpoint
    2. The program should follow the first branch
    3. The output should display Wear a rain jacket.
    4. 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.

    Go to top
  5. 5. Trace the Other Path

    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

    1. Before running, predict the displayed recommendation
    2. Use the same breakpoint on if (isRaining)
    3. Run the application and click Choose Clothing
    4. Verify isRaining is now false
    5. Use F10 and observe the program skip the true block and enter the else block
    Screenshot placeholder showing Visual Studio paused at the clothing decision with isRaining equal to false
    The same decision now follows the false path because the Boolean state changed.

    Check Your Work

    1. The output should display Wear a hoodie.
    2. Only the Boolean value changed; the decision structure stayed the same
    3. The observed path should match the false path in the activity diagram
    Go to top
  6. 6. Connect the Checkbox to the Boolean

    So far, the program has been told whether it is raining by a value typed directly into C#. Now the user interface will supply that true/false state.

    Step 1 — Replace the hardcoded Boolean

    Replace the current bool isRaining = ... line with the supplied line below. Do not change the if/else statement.

    MainWindow.xaml.cs — replace only the isRaining assignment
    bool isRaining = this.rainCheckBox.IsChecked == true;

    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

    1. Leave It is raining unchecked
    2. Run to the breakpoint on if (isRaining)
    3. Verify isRaining is false
    4. Use F10 to verify the hoodie path runs

    Step 3 — Test the checked state

    1. Stop and restart the application if needed
    2. Check It is raining
    3. Click Choose Clothing
    4. At the breakpoint, verify isRaining is true
    5. Use F10 to verify the rain-jacket path runs
    Screenshot placeholder connecting the checked rain checkbox with isRaining equal to true in the debugger
    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.

    Activity diagram: user checks or unchecks It is raining; the application reads the checkbox state and assigns isRaining true or false; if true it recommends a rain jacket, otherwise a hoodie; then it displays the recommendation.
    Completed 0.3 activity flow from checkbox state to clothing recommendation.

    Check Your Work

    1. Unchecked checkbox → isRaining is false → hoodie
    2. Checked checkbox → isRaining is true → rain jacket
    3. 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.

    Go to top
  7. 7. Final Check and Submit

    Before submitting, verify the complete 0.3 checkpoint and then submit the entire Visual Studio solution through the required course workflow.

    Step 1 — Complete the final technical check

    Step 2 — Zip the solution

    1. Close Visual Studio
    2. In File Explorer, locate the LastName parent folder that contains your .sln file and project folder
    3. Create a ZIP file of the entire solution folder
    4. Open the ZIP and confirm it contains the solution file and the FirstDayScenario project folder

    Step 3 — Submit to the Feedback System

    1. Open the Feedback System
    2. Select the correct First Day 0.3 assignment
    3. Upload the ZIP file
    4. Review the Feedback System results and correct any in-scope issues if required
    5. Resubmit a corrected ZIP when needed

    Step 4 — Submit the Feedback System URL to Canvas

    1. After the required Feedback System submission is ready, copy its URL
    2. Open the correct 0.3 First Day Assignment in Canvas
    3. 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.

    © 2026 Northcentral Technical College

    Go to top