All pastes #383211 Raw Edit

cs149 actionperf

public text v1 · immutable
·published 2007-03-06 05:14 UTC
rendered paste body
if (source == buttStart) // this should work, but the scroller pane
		// doesn't update
		{
			// Set up the simulator for Preemptive Priority. -KF
			if (PP) {
				JobFeeder feeder;
				PPQueue queue = new PPQueue(true, 30000);
				int oHead;

				try {

					// Parse and check the overhead value from its text
					// field. -KF
					oHead = Integer.parseInt(overhead.getText());
					if (oHead < 0)
						throw new NumberFormatException();

					// Construct a Simulator object and run it. -KF
					feeder = new JobFeeder("test2.txt");
					sim = new Simulator(oHead, queue, feeder);
					sim.run();
				} catch (NumberFormatException numErr1) {
					JOptionPane.showMessageDialog(this,
							"The overhead must be an integer >= 0.");
				} catch (IOException e) {
					JOptionPane.showMessageDialog(this,
							"The text file containing the jobs to be"
									+ " run does not exist or is invalid.");
				}
			}

			// Set up the simulation for Round Robin. -KF
			else {
				JobFeeder feeder;
				RRQueue queue;
				int oHead;
				int tSlice;

				try {

					// Parse and check the overhead value from its text
					// field. -KF
					oHead = Integer.parseInt(overhead.getText());
					if (oHead < 0)
						throw new NumberFormatException();

					// Parse and check the time slice value from its text field. -KF
					tSlice = Integer.parseInt(timeSlice.getText());
					if (tSlice < 1)
						throw new IllegalArgumentException();
					queue = new RRQueue(tSlice);

					// Construct a Simulator object and run it. -KF
					feeder = new JobFeeder("test2.txt");
					sim = new Simulator(oHead, queue, feeder);
					sim.run();
				} catch (NumberFormatException numErr1) {
					JOptionPane.showMessageDialog(this,
							"The overhead must be an integer >= 0");
				} catch (IllegalArgumentException numErr2) {
					JOptionPane.showMessageDialog(this,
							"The time slice must be an integer > 0.");
				} catch (IOException e) {
					JOptionPane.showMessageDialog(this,
							"The text file containing the jobs to be"
									+ " run does not exist or is invalid.");
				}
			}
		}