import objectdraw.*; import java.awt.*; import java.util.Random; /** * Selects the order of lab sections for the CS 1101 final exam. */ public class ExamOrderPicker extends FrameWindowController { // window dimensions private static final int WINDOW_HEIGHT = 300, WINDOW_WIDTH = 750; // display font size private static final int FONT_SIZE = 24; // position of the text display private static final Location TEXT_POS = new Location(50, 100); // number of lab sections to choose from private static final int NUM_SECTIONS = 2; // text display showing the results private Text output; // whether we've already picked a section private boolean selected = false; public void begin() { resize(WINDOW_WIDTH, WINDOW_HEIGHT); output = new Text("Starting with Written portion: ", TEXT_POS, canvas); output.setFontSize(FONT_SIZE); } // select a lab section if we haven't already public void onMouseClick(Location point) { if (!selected) { Random rand = new Random(); if (rand.nextInt(NUM_SECTIONS) == 0) { output.setText(output.getText() + "MONDAY lab section"); } else { output.setText(output.getText() + "TUESDAY lab section"); } selected = true; } } }