A.
Block 1: out.println("FACTORY REPORT\n");
Block 2: From there until out.print ("Robot");
Block 3: From out.print ("Robot"); through write("\n");
Block 4: out.println("=======\n");
You might have chosen a slightly different set of blocks. B.
public static void report (
PrintStream out, List machines, Robot robot) {
reportHeader(out);
reportMachines(out, machines);
reportRobot(out, robot);
reportFooter(out);
}
We wouldn't stop here, but this would be a good first step. (We could either move toward a Report class or toward putting report() methods on the Machine and Robot classes.) C. Does it make sense to extract a one-line method? Yes, if it communicates better. |