11.1c — Create PT: Build Day 2
Day 1 built the list (11.1b); today builds the ALGORITHM — the procedure that earns its rubric row by doing all three at once: sequencing (statements in order), selection (if), iteration (loop). This is the piece the video will feature and WR2a will explain. Make it proud.
The algorithm contract — annotate yours to match:
// SEQUENCING: these lines run in THIS order, on purpose
public int ScoreHand(List<Card> cards, int bonus) // ← parameters
{
int total = 0; // 1. start
for (int i = 0; i < cards.Count; i++) // 2. ITERATION
{
Card c = cards[i];
if (c.cost <= 3) // 3. SELECTION
{
total += c.attack + bonus;
}
else
{
total += c.attack / 2;
}
}
if (total > 20) { total = 20; } // 4. SELECTION, again
return total; // 5. output
}
Why the exam loves this shape: it is not hard; it is COMPLETE. Sequencing is the spine, selection makes decisions, iteration handles many items, and the procedure takes PARAMETERS so callers can reuse it. Your 10.2d AI score method IS this algorithm — you have been writing rubric answers all year without knowing the rubric's name.
Build order for the day:
- Write the procedure with parameters (two beats: what it processes, what it decides on). Name the parameters well — they appear in your screenshots and WR.
- Call it from three different places — a call per context proves reuse, and graders read calls as "this is real behavior, not a demo."
- Print before/after: Debug.Log(...) the input state and output state at each call site. Input → behavior → output, made visible.
- Break it on purpose (5 min): empty list, zero, one item, giant item. Fix what crashes. The PT video cannot crash — you have ONE take.
Socratic: Sequencing, Selection, Iteration
- Your procedure does all three at once. Which line is the selection, and what would happen if it were deleted?
- A grader must be able to find the parameter and the call. Can you name both from memory without opening the file?
- You built this before the input and output the video will show. What is the risk in that order, and what did you do about it today?
Checkpoint — before moving on, you must be able to:
- Label S/S/I in your algorithm line by line
- Show three call sites with different arguments
- Prove the algorithm survives edge inputs
- Read your WR2a paragraph out loud in under 40 seconds
Reference Docs
Need a deeper explanation? These pages cover the same concepts:
- Create PT guide — the algorithm rubric rows
- Written Responses — how WR2a is graded
Saved on this device only — the Dashboard tracks your progress.