Пример #1
0
  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++;
    }
  }
Пример #2
0
  public void assignAircraftToRunway(Aircraft aircraft) {
    if (!inUse) {
      // Mark runway as being in use
      inUse = true;

      // Add aircraft to runway
      aircraftUsingRunway = aircraft;

      // Initiate the landing/departing sequence of the aircraft about to land
      aircraftUsingRunway.act();
    } else {
      // Runway already in use

      // TODO: Throw runwayAlreadyInUse exception
    }
  }
Пример #3
0
 public void displayFlightInfo() {
   System.out.println(
       "Flight "
           + getFlightNumber()
           + " in the "
           + aircraft.getAircraftType()
           + " is ready for boarding.");
   System.out.println("Here is the final boarding list for this flight:\n");
   for (Passenger p : passCollection) {
     if (p.getStatus()) setAmount(112.50);
     else setAmount(75.00);
     System.out.println(
         p.getFirstName()
             + " "
             + p.getLastName()
             + " - "
             + (p.getStatus() ? "FIRST CLASS" : "ECONOMY CLASS")
             + " passenger. $"
             + getAmount()); // (p.getStatus()? 112.50 : 75.00));
   }
 }
Пример #4
0
 public AircraftFlightDay(Aircraft aircraft) {
   super();
   this.aircraftKey = aircraft.getKey();
 }
Пример #5
0
  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++;
    }
  }