public void generateTakeoff() { Random rand = new Random(); // new random number if (rand.nextDouble() <= Glider.getProbability()) { // if number matches the Glider's probability Aircraft ac = new Glider(); // create new Glider object ac.setPrefix("tk_"); // debug info ac.setNumber(tcounter); // debug info to.addAircraft(ac); // add aircraft to the queue tcounter++; } else if (rand.nextDouble() <= (Glider.getProbability() + LightAircraft .getProbability())) { // if number matches the Light Aircraft's probability Aircraft ac = new LightAircraft(); // create new LightAircraft object ac.setPrefix("tk_"); // debug info ac.setNumber(tcounter); // debug info to.addAircraft(ac); // add aircraft to the queue tcounter++; } else if (rand.nextDouble() <= (Glider.getProbability() + LightAircraft.getProbability() + Commercial .getProbability())) { // if number matches the Commercial Aircraft's probability Aircraft ac = new Commercial(); // create new Commercial object ac.setPrefix("tk_"); // debug info ac.setNumber(tcounter); // debug info to.addAircraft(ac); // add aircraft to the queue tcounter++; } }
public void generateLanding() { Random rand = new Random(); // new random number if (rand.nextDouble() <= Glider.getProbability()) { // if number matches the Glider's probability Aircraft ac = new Glider(); // create new Glider object ac.setPrefix("ln_"); // debug info ac.setNumber(lcounter); // debug info ln.addAircraft(ac); // add aircraft to the queue lcounter++; } else if (rand.nextDouble() <= (Glider.getProbability() + LightAircraft .getProbability())) { // if number matches the Light Aircraft's probability Aircraft ac = new LightAircraft(); // create new LightAircraft object Random gen = new Random(42); // Or choose a different seed int flyingTime = gen.nextInt(20) + 20; // time measured in half-minutes ac.setFuel(flyingTime); // set amount of fuel for the aircraft ac.setPrefix("ln_"); // debug info ac.setNumber(lcounter); // debug info ln.addAircraft(ac); // add aircraft to the queue lcounter++; } else if (rand.nextDouble() <= (Glider.getProbability() + LightAircraft.getProbability() + Commercial .getProbability())) { // if number matches the Commercial Aircraft's probability Aircraft ac = new Commercial(); // create new Commercial object Random gen = new Random(42); // Or choose a different seed int flyingTime = gen.nextInt(40) + 40; // time measured in half-minutes ac.setFuel(flyingTime); // set amount of fuel for the aircraft ac.setPrefix("ln_"); // debug info; //debug info ac.setNumber(lcounter); // debug info ln.addAircraft(ac); // add aircraft to the queue lcounter++; } }