๐ WAYPOINT LESSON
The Q3 shape
โญโญ intermediateโณ 12 min read๐ Lesson 141 of 256
Provided class + one method; count, match, process; prose obligations.
Q3 hands you a provided class and asks you to write ONE method โ the whole question is that method. The list usually holds objects:
// provided:
public class Order {
private String customer;
private int cents;
public Order(String c, int cents) { customer = c; this.cents = cents; }
public String getCustomer() { return customer; }
public int getCents() { return cents; }
}
// to write: total for one customer
public int customerTotal(ArrayList<Order> orders, String name) { ... }
The Q3 playbook is three verbs:
- count โ how many orders belong to "Ana"? (filter + counter)
- match โ find the first/last order matching a condition (filter + sentinel)
- process โ aggregate or transform (filter + accumulator)
Every Q3 answer is a for-each (reading) or indexed loop (mutating) plus one machine. The wrapper class changes; the machines never do. The exam's twist is usually in the specification prose: "adjacent duplicates count once", "orders before the first rejection only", "ties broken by earliest" โ underline those phrases; they are the obligations that separate 6 from 9.