Rubber Duck Saga — Entry Log
TTG’s prompt • C.R.A.F.T. critique • APCS-A teaching notes • Vibe-coding prompts
Entry-specific companion to the Tool Time chatlog
Entry-specific development log for Tool Time Entry #8: Rubber Duck Saga. The deepest Java entry in the series so far — three classes, a pipe-delimited data file, four active TODOs, and an eight-stage progression from “run it” to “sort and search an ArrayList.”
This log covers: TTG’s Session 1 prompt (entry build) with C.R.A.F.T. critique and grade; Session 2 prompt (data file showcase + Null anomaly) with critique; design decisions; APCS-A teaching notes; and four ready-to-use C.R.A.F.T. prompt examples for students who want to vibe-code the entry to completion.
You are a co-developer at TNT, an APCS-A teacher of Java, an APCS-A grader for the College Board and an exceptional ‘Vibe Coder’. I have provided you an overview of our ‘Tool Time’ idea in a markdown file as well as an example of another Java application where we provide some initial code that needs an AI-assisted upgrade. We’d like to do the same thing with the ‘RubberDuck’ Saga in Java. I have some initial code that models the creation of RubberDuck objects and Owner objects with ‘driver’ code that currently works but is incomplete. It has a few ‘todo’ items listed, as well as a header comment that lays out where we’d like to go with the project. I’ve also included a datafile in text that should be used to create an ArrayList of RubberDucks to be sorted in various ways and searched in various ways. Let’s create rubberDuckOriginal.html with associated rubberDuckOriginalStyles.css that lets users copy and run the original code in JDoodle, and hopefully have AI help to improve and extend it. To showcase our development, let’s also create rubberDuckChatlog.html with rubberDuckChatlogStyles.css to chronicle our development and critique our prompts as you did with the examples provided with the threeStooges application. I have provided artwork for the hero background and card image for the ToolTime card on the home page. We’ll need to ‘wireup’ the card to our application for this app.
A rich, context-loaded prompt with four distinct roles, six attached context files, named deliverables, and an explicit request for home page wiring. The strongest context package in the Java entry series. The main gap is in pedagogical precision — the APCS learning targets are broad where they could be specific.
✅ Strengths
⚠️ Growth Areas
threeStoogesOriginalScripts.js (explicitly in the structural precedent). The equivalent rubberDuckOriginalScripts.js is implied by the pattern reference but was never stated. The A+ is one file name away.public static void main explanation). Naming even two here — e.g., “sort by goodGuyScale descending and search by affiliation” — would have sharpened the APCS content focus.//todo comments. The prompt doesn’t mention them. As a result, whether to highlight them as challenges, fill them in automatically, or leave them for students was left to AI judgment. Saying “the TODOs in the source are deliberate teaching challenges — highlight them in the page” would have made that intent unambiguous.Grade rationale: A−. The context package is the strongest in the Java entry series — six files including the data file is excellent prompting discipline. The pedagogy gap (broad sort/search targets vs. named APCS outcomes) prevents the A+. One paragraph of specifics about APCS targets and the scripts filename would push this to A+.
Counting live entries in the gallery: Entry #1 (Jackson’s Iris, p5.js), #2 (Sean’s Weightlifter, p5.js), #3 (Sebastian’s Ship, p5.js), #4 (Ethan’s Baby Shark, p5.js), #5 (Beau’s Purple Rain, p5.js), #6 (Three Stooges Driver, Java), #7 (Xmas Lights, Python Processing) — Rubber Duck Saga takes slot #8. Added to the second Bootstrap row alongside entries 4–7 in toolTimeHome.html; it flows onto a new visual row on large screens alongside Entry #7.
The Three Stooges entry used vintage B&W film sepia (#c49a20) on near-black (#0e0e0e). For Rubber Duck Saga, the subject matter provides an unmistakable palette: the yellow of the ducks themselves (--rd-yellow: #f5c218) and the blue of the bath water / studio setting (--rd-blue: #2496b4), against a deep navy background (--rd-dark: #07111c).
The yellow replaces the Three Stooges’ sepia as the primary accent: borders, headings, badges, and TODO highlights. The blue handles the code terminal, decision boxes, and teaching boxes. Both colors are warm/cool enough to maintain high contrast on the dark background across both HTML files.
The original source has three classes (RDuckDriver_Stg0, RubberDuck, Owner) in one .java file. Only RDuckDriver_Stg0 is public; the other two are package-private. This is the standard APCS-A multi-class pattern for assignments where students submit one file. The intro card calls this out explicitly — it is a teaching point in its own right.
Decision: preserve the single-file structure in the showcase. Do not split into three files. The whole point is for students to understand why the file is structured this way and what the rules are.
The Three Stooges entry had five stages because the code was 10 lines with one learning target: ArrayList + no duplicates. The Rubber Duck entry starts with three full classes, four TODO items, and a data pipeline goal. Eight stages are needed to build in proper increments:
- Run it & read breadcrumbs
- Understand the multi-class structure
- Complete the default constructor
- Override
toString()in RubberDuck - Finish
gradeLabel() - Add parameterized constructor + getters
- Load from the data file
- Sort & search the ArrayList
Each stage is a runnable checkpoint. Students can stop at any stage and have working code.
The data file contains two records where characterName = "Null". These are placeholder entries for students who were absent and haven’t drawn a duck yet. They are intentional and appear in the real class roster.
Decision: mention them explicitly in Stage 7 as a real-world defensive programming moment. The file I/O code must handle them: check for parts[0].equals("Null") and either skip those records or create a placeholder duck with a flag. This models a practice that is universal in production data pipelines.
The data file (rDuckData_Stg0.txt) is pipe-delimited because commas appear in some character names. The 9-field format is documented in the file’s own header comments. Stage 7 of the Your Turn section shows the exact field order and calls out the two key Java gotchas: (1) split("\\|") requires a double-escaped backslash because | is a regex special character; (2) Integer.parseInt() is needed to convert String digits to int. Both are common sources of APCS-level confusion.
Because some ambitious novices may want to start early with loading the datafile, let’s include it in our original page, with a ‘Copy’ option so that data can be used in an IDE to load a ‘class set’ (pardon the pun) of RubberDuck and Owner data. Let’s include this prompt and it’s analysis in our chatlog, and make the necessary re-writes to the original file to orient a user as to what the datafile is and how it can be used. We should showcase the fact that as of its loading, there are two Owners who have not been assigned RubberDucks! We’ll need to deal with that anomaly with our code!
A focused iterative follow-up that correctly identifies the missing piece (data file on page) and the key pedagogical hook (Null anomaly). Clear intent, good pun discipline, specific anomaly call-out. Held back from A range by vague action language and no visual specification.
✅ Strengths
⚠️ Growth Areas
Grade rationale: B+. Strong iterative instinct and excellent anomaly identification. The vague “necessary re-writes” + no visual spec + no anomaly strategy prevent the A. If the action had named Stage 7 explicitly and specified “show three handling strategies,” this would be A−.
The data file showcase card is inserted between the Java code card and the Your Turn stages. This creates a natural reading sequence: “here’s the OOP scaffold → here’s the data it will load → here’s how to do it.” Placing it after the Java code means students already understand the class structure when they first see the data format. Placing it before the stages means they can study the format before they attempt Stage 7.
The Java code uses blue-striped rows (rgba(36,150,180,...)) on a near-black background — a cool-toned terminal aesthetic. The data file uses yellow-striped rows (rgba(245,194,24,...)) on a warmer dark background (#0d0a00). Two different display formats that share the same line-number, counter, and monospace font conventions but are immediately visually distinct.
The `.data-terminal-header` and `.data-copy-btn` are yellow-accented versions of their blue counterparts. A field legend strip sits between the terminal header and the data display, giving students a quick reference for the 9 fields (indices 0–8) without opening a separate document.
populateDataFile() in rubberDuckOriginalScripts.js inspects each line as it renders. Lines starting with # get .data-comment (dimmed italic yellow). Lines starting with Null| get .data-null (red text, red-tinted background override). The two anomaly lines are therefore visually flagged in the data display itself, not just called out in a text box below.
This is a design-level teaching moment: the anomaly is visible in the raw data before a single line of Java is written. Students who stare at the data before coding will see the problem immediately. This mirrors real-world data quality practice: inspect your source before building your pipeline.
The anomaly callout (.anomaly-box) sits inside the data showcase card between the data display and the attr-strip — not as a separate section below the card. This keeps the anomaly physically connected to the data lines it describes. Students scrolling past the data card encounter the warning as part of examining the data, not as a detached commentary. The red top border of the anomaly box creates a visual “emergency stop” between the data and the attribution strip.
The original Stage 7 mentioned the Null entries as a “handle them gracefully” footnote. The revised Stage 7 names three distinct strategies:
- Skip — one-line guard; simplest; ignores the absent students entirely.
- Flag — adds a
boolean isUnassignedivar; preserves the owner count; more OOP. - Separate list — maintains a second
ArrayList<Owner>; produces the most informative output.
Having three strategies moves Stage 7 from a file I/O exercise to a design exercise. This directly matches APCS-A Free Response question style, which asks students to choose an approach and defend it — not just fill in boilerplate.
Java allows multiple classes in a single .java file, but only one may be declared public — and that class’s name must exactly match the filename. All other classes in the file are package-private (no access modifier). This is not a quirk; it is the standard pattern for APCS-A multi-class submissions.
Common student misconception: “each class needs its own file.” This entry addresses that directly. The breadcrumb output proves that all three classes are active in one compilation unit.
The Object class provides a free default (no-arg) constructor — but only until you define any constructor yourself. Once you write a parameterized constructor, the free default disappears and you must write your own explicit default if you want one. Stage 0 has only a default constructor. Stage 6 adds the parameterized one alongside it, modeling the “provide both” pattern that APCS-A FRQs frequently test.
The //todo: finish this code line in the default constructor is deliberate: an empty default constructor compiles and runs, but every ivar will be null or 0 until initialized. Students discover this naturally when they add toString() in Stage 4 and get null output.
The original code has a commented-out line and a live one that demonstrate this perfectly:
//System.out.println("testOwner lives at: " + testOwner); // prints mem address
System.out.println(testOwner); // prints "Fred | Station 1 | Freshman | Period 2"
The first line would print a memory address (hash code) if uncommented. The second line triggers Owner.toString() because Owner overrides it. RubberDuck does not override it in Stage 0 — so System.out.println(d0) prints a memory address. This contrast is the entire motivation for Stage 4.
APCS-A FRQs frequently ask students to write toString(). This entry models the method, the override annotation, and the pipe-delimiter convention.
All six instance variables in both RubberDuck and Owner are private. This is APCS-A encapsulation canon. But private creates a problem the moment you try to sort from outside the class: Collections.sort() with a Comparator calls methods on the objects but cannot access their fields directly.
Stage 6 makes getters a prerequisite for Stage 8. This is not arbitrary scaffolding — it is the actual dependency order in real Java OOP. Students who write the getters in Stage 6 understand why they need them when they reach Stage 8.
Owner.gradeLabel(int g) is declared static. It does not need an Owner instance to run — it converts an integer to a label using only its own parameter. That is the entire definition of when to use static for a utility method: no instance state required.
Students often make utility methods instance methods by default. gradeLabel() is a clean example of a correct static utility method. Stage 5 extends it with a switch statement, which also demonstrates Java’s canonical switch-as-dispatch pattern.
The goodGuyScale ivar (1–5, where 1 is Villain and 5 is Hero) is an int that encodes a category. This is a common OOP modeling pattern: store a compact integer, provide a helper that makes it human-readable. It is exactly the same pattern as grade + gradeLabel() in Owner.
Stage 4 asks students to write heroLabel(int scale) using the same approach. Seeing the pattern twice — once modeled, once independently written — reinforces it. This is the deliberate pedagogical structure of Stages 3–5.
Stage 7 introduces Scanner(new File(filename)). Two specific Java gotchas are built into the data format by design:
- Regex pipe escape:
split("|")does nothing (pipe is a regex alternation operator);split("\\|")works. Students who forget the escape get a runtime array of individual characters instead of fields. - Null sentinel check: Two records have
characterName = "Null". Without a defensive check, they produceRubberDuckobjects with the name “Null” in the ArrayList — a subtle data quality bug.
Both gotchas mirror real-world data pipeline bugs. Finding them, understanding them, and fixing them is the core of Stage 7.
“You are a patient APCS-A Java teacher. I have a Java file with three classes: RDuckDriver_Stg0 (driver), RubberDuck, and Owner. (1) Complete the default constructor for RubberDuck — initialize characterName and nickName to ‘Unknown’, affiliation to ‘Unaffiliated’, age and goodGuyScale to 0, and owner to null. (2) Override toString() in RubberDuck showing all five non-owner ivars, using the same pipe separator style as Owner.toString(). Include a static heroLabel(int scale) helper that maps 1–5 to Villain/Mostly Bad/Neutral/Mostly Good/Hero. (3) Complete Owner.gradeLabel() for grades 9 (Freshman), 10 (Sophomore), 11 (Junior), 12 (Senior) using a switch statement. Show only the changed methods with a comment explaining each change.”
Tests: default constructor, toString() override, @Override annotation, switch statement, static utility methods, breadcrumb discipline.
“You are a patient APCS-A Java teacher. My RubberDuck class currently has only a default constructor. (1) Add a parameterized constructor that takes: String characterName, String affiliation, String nickName, int age, int goodGuyScale. Initialize all five ivars from the parameters and set owner to null. (2) Add six public getter methods: getCharacterName(), getAffiliation(), getNickName(), getAge(), getGoodGuyScale(), and getOwner(). (3) In the main method, create an ArrayList<RubberDuck> and manually add four ducks using the parameterized constructor. Print the list with a for-each loop. Show the complete updated class with comments.”
Tests: parameterized constructor, getter methods, ArrayList declaration, for-each loop, ArrayList.toString() behavior.
“You are a patient APCS-A Java teacher. I have a pipe-delimited data file with 9 fields per line: characterName|affiliation|nickName|age|goodGuyScale|stationNumber|ownerFirstName|ownerGrade|period. Comment lines start with #. Some entries have characterName = ‘Null’ (absent students). Write a static method readDucks(String filename) that: opens the file with Scanner(new File(filename)), skips blank lines and lines starting with #, skips lines where parts[0] equals ‘Null’, creates a RubberDuck using the parameterized constructor for fields 0–4, creates an Owner using fields 5–8, links them with duck.setOwner(owner), and returns an ArrayList<RubberDuck>. Add throws Exception to the method signature. Show the complete method with comments explaining the pipe escape and parseInt calls.”
Tests: Scanner with File, split("\\|"), Integer.parseInt(), throws Exception, Null sentinel handling, ArrayList population.
“You are a patient APCS-A Java teacher. I have an ArrayList<RubberDuck> with 20 ducks loaded from a data file. Write three static utility methods in my driver class: (1) sortByHeroism(ArrayList<RubberDuck> ducks) — sorts descending by goodGuyScale (Heroes first) using Collections.sort() with a Comparator. (2) sortByAge(ArrayList<RubberDuck> ducks) — sorts ascending by age. (3) searchByAffil(ArrayList<RubberDuck> ducks, String target) — returns a new ArrayList containing only ducks whose affiliation matches target using equalsIgnoreCase(). Include imports for ArrayList, Collections, and Comparator. Show all three methods with comments.”
Tests: Collections.sort(), Comparator.compare() return value convention, equalsIgnoreCase(), new ArrayList as return type, import discipline.
Once Stage 8 is complete, here are four natural extensions:
- Sort by ownerGrade — sort the roster by the owner’s grade level (Freshmen first, Seniors last). Requires accessing the Owner through the duck’s getter.
- Group by period — split the ArrayList into two: Period 1 and Period 7. Use two ArrayLists and an if statement on
d.getOwner().getPeriod(). - Binary search after sorting — sort alphabetically by characterName, then use
Collections.binarySearch()with a Comparator. Compare the runtime efficiency with linear search. - Add an Owner reference to RubberDuck and a RubberDuck reference to Owner — the original TODO asks exactly this question. This creates a bidirectional relationship. What problem does it introduce? (Infinite recursion in
toString()if you’re not careful.)