Esempio n. 1
0
 /**
  * The action classes takes in the usesr choice and then determines the correct response to send
  * to the Plane Clas.
  *
  * @param c takes in a string that is what the user input from the menu to do
  */
 public void action(String c) {
   if (c.equals("reserve")) // if the command was to reserve
   {
     plane.makeReservation(); // calls the method
   }
   if (c.equals("cancel")) // if the commmand was to cancel
   {
     plane.cancelSeat(); // calls the method
   }
   if (c.equals("seat")) // if the command was to view the seat
   {
     plane.displaySeat(); // calls the displayseat method
   }
   if (c.equals("plane")) // if the command was to view the plane
   {
     plane.displayPlane(); // calls the displayPlane method
   }
   if (c.equals("search")) // of the command was to serach for a passanger
   {
     System.out.println("Enter the person you would like to look for. (first name) : ");
     String name = scan.nextLine();
     plane.searchPassenger(name); // sends the name inputed to the plane class
   } else if (c.equals("quit")) // if chooice is quit then it ends the program
   System.out.println("Thank you for using Joe's Airline");
 }
Esempio n. 2
0
  protected double intersectsAt(
      Plane plane, double effectiveRadius, Vec4 endpoint1, Vec4 endpoint2) {
    // Test the distance from the first end-point.
    double dq1 = plane.dot(endpoint1);
    boolean bq1 = dq1 <= -effectiveRadius;

    // Test the distance from the possibly reduced second end-point.
    double dq2 = plane.dot(endpoint2);
    boolean bq2 = dq2 <= -effectiveRadius;

    if (bq1
        && bq2) // endpoints more distant from plane than effective radius; box is on neg. side of
      // plane
      return -1;

    if (bq1 == bq2) // endpoints less distant from plane than effective radius; can't draw any
      // conclusions
      return 0;

    // Compute and return the endpoints of the cylinder on the positive side of the plane.
    this.tmp3.subtract3AndSet(endpoint1, endpoint2);
    double t = (effectiveRadius + dq1) / plane.getNormal().dot3(this.tmp3);

    this.tmp3.subtract3AndSet(endpoint2, endpoint1).multiply3AndSet(t).add3AndSet(endpoint1);
    // truncate the line to only that in the positive halfspace (e.g., inside the frustum)
    if (bq1) endpoint1.set(this.tmp3);
    else endpoint2.set(this.tmp3);

    return t;
  }
Esempio n. 3
0
 public int getNumOfClean() {
   int cleanBlocks = 0;
   for (Plane<?, ?> plane : planesList) {
     cleanBlocks += plane.getNumOfClean();
   }
   return cleanBlocks;
 }
 //    @Ignore
 @Test
 public void testGetOrigin() {
   final int capacity = 180;
   final int emptySeats = 6;
   final Vehicle vehicle = new HL777b("BERLIN-NICE", capacity, emptySeats);
   final Plane plane = new VehicleAdapter(vehicle);
   assertEquals(plane.getOrigin(), "berlin");
   System.out.println("Origin test OK");
 }
 //     @Ignore
 @Test
 public void testGetDestination() {
   final int capacity = 180;
   final int emptySeats = 6;
   final Vehicle vehicle = new HL777b("NICE-BERLIN", capacity, emptySeats);
   final Plane plane = new VehicleAdapter(vehicle);
   assertEquals(plane.getDestination(), "nice");
   System.out.println("Destination test OK");
 }
 /** Test of getPassengerCount method, of class VehicleAdapter. */
 @Test
 public void testGetPassengerCount() {
   final int capacity = 180;
   final int emptySeats = 6;
   final int expectedPassengers = 174;
   final Vehicle vehicle = new HL777b("BERLIN-NICE", capacity, emptySeats);
   final Plane plane = new VehicleAdapter(vehicle);
   assertEquals(plane.getPassengerCount(), expectedPassengers);
   System.out.println("Passenger test OK");
 }
 public void planeFiller() throws IOException {
   Plane airbusA320 = new Plane();
   HumanGenerator generator = new HumanGenerator();
   int people = 0, group = 0;
   airbusA320.writeSeats();
   while (people < 162) {
     System.in.read();
     group = generator.generateHumans();
     if (airbusA320.fillSeats(group) == true) {
       airbusA320.writeSeats();
       people += group;
     }
   }
 }
 public synchronized void swapBuffers() {
   Map<Character, Plane> ret = new HashMap<Character, Plane>();
   frontBuffer = new HashMap<Character, Plane>();
   previousAdds = new HashMap<Gate, Integer>();
   for (Map.Entry<Character, Plane> e : backBuffer.entrySet()) {
     char key = e.getKey().charValue();
     Plane p = e.getValue().clone();
     frontBuffer.put(key, p);
     ret.put(key, p.clone());
   }
   actualAdds = new HashMap<Gate, Integer>();
   setChanged();
   notifyObservers(ret);
 }
Esempio n. 9
0
 /** @param args the command line arguments */
 public static void main(String[] args) {
   System.out.println("Welcome to Oswego Airlines");
   Scanner sc = new Scanner(System.in);
   System.out.println("Enter a flight number:");
   String flight = sc.nextLine();
   System.out.println("Enter the number of rows:");
   int rows = sc.nextInt();
   sc.nextLine();
   System.out.println("Enter the number of seats per row:");
   int seats = sc.nextInt();
   sc.nextLine();
   Plane plane = new Plane(flight, rows, seats);
   while (true) {
     System.out.println("Enter add, remove, seats, list, or quit:");
     String choice = sc.nextLine();
     switch (choice) {
       case "add":
         System.out.println("Enter passenger name, row, and seat:");
         String name;
         if (plane.addPassenger((name = sc.next()), sc.nextInt(), sc.nextInt())) {
           System.out.println("Passenger " + name + " was added.");
         } else {
           System.out.println("Invalid seat -- please try again.");
         }
         sc.nextLine();
         break;
       case "remove":
         System.out.println("Enter row and seat:");
         if (plane.removePassenger(sc.nextInt(), sc.nextInt())) {
           System.out.println("Passenger was removed.");
         } else {
           System.out.println("Invalid seat -- please try again.");
         }
         sc.nextLine();
         break;
       case "seats":
         plane.showSeats();
         break;
       case "list":
         plane.passengerList();
         break;
       case "quit":
         System.out.println("Closing Oswego Airlines");
         return;
       default:
         System.out.println("Unknown command -- please try again.");
     }
   }
 }
Esempio n. 10
0
  /** {@inheritDoc} */
  public double getEffectiveRadius(Plane plane) {
    if (plane == null) return 0;

    // Determine the effective radius of the box axis relative to the plane.
    Vec4 n = plane.getNormal();
    return 0.5 * (Math.abs(this.s.dot3(n)) + Math.abs(this.t.dot3(n)));
  }
Esempio n. 11
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   FlightRecord other = (FlightRecord) obj;
   if (cancellationInfo == null) {
     if (other.cancellationInfo != null) return false;
   } else if (!cancellationInfo.equals(other.cancellationInfo)) return false;
   if (date == null) {
     if (other.date != null) return false;
   } else if (!date.equals(other.date)) return false;
   if (flightID == null) {
     if (other.flightID != null) return false;
   } else if (!flightID.equals(other.flightID)) return false;
   if (isCancelled != other.isCancelled) return false;
   if (isDiverted != other.isDiverted) return false;
   if (passengers == null) {
     if (other.passengers != null) return false;
   } else if (!passengers.equals(other.passengers)) return false;
   if (plane == null) {
     if (other.plane != null) return false;
   } else if (!plane.equals(other.plane)) return false;
   return true;
 }
Esempio n. 12
0
  public void displayMenu() {
    System.out.println("------------------------------");
    System.out.println("------------------------------");
    System.out.println("---Weclome to Joes Airlines---");
    System.out.println("------------------------------");

    while (!choice.equals(
        "quit")) // if the users does not type quit then display the menu after the command for that
                 // option has been completed
    {
      if (!display) // makes the boolean false so that it can run once
      {
        plane.initPlane(); // initlizees the plane
        display = true; // sets the boolean to true and ends the if statement
      }
      System.out.println();
      System.out.println("Menu");
      System.out.println("1. Reserve(Seat)");
      System.out.println("2. Cancel(Seat)");
      System.out.println("3. Seat(View)");
      System.out.println("4. Plane(View)");
      System.out.println("5. Search(Name)");
      System.out.println("6. Quit(System)");

      System.out.println("Enter Users Choice: ");
      choice = scan.nextLine();
      this.action(choice); // sends the users choice to the method below
    }
  }
 @Override
 public double computeDistance(
     final PlanetModel planetModel,
     final Plane plane,
     final GeoPoint point,
     final Membership... bounds) {
   return plane.linearDistanceSquared(planetModel, point, bounds);
 }
Esempio n. 14
0
 @Override
 public boolean isWithin(final double x, final double y, final double z) {
   return minXPlane.isWithin(x, y, z)
       && maxXPlane.isWithin(x, y, z)
       && yPlane.evaluateIsZero(x, y, z)
       && minZPlane.isWithin(x, y, z)
       && maxZPlane.isWithin(x, y, z);
 }
Esempio n. 15
0
  public ArrayList<Plane> getPlanes() {

    Plane plane;
    ArrayList<Plane> out = new ArrayList<Plane>();
    ArrayList<Point3D> add = new ArrayList<Point3D>();
    add.add(lines.get(0).point1);
    add.add(lines.get(1).point1);
    add.add(lines.get(2).point1);
    add.add(lines.get(3).point2);
    plane = new Plane(add);
    plane.color = color;
    out.add(plane);

    add = new ArrayList<Point3D>();
    add.add(lines.get(4).point1);
    add.add(lines.get(5).point1);
    add.add(lines.get(6).point1);
    add.add(lines.get(7).point2);
    plane = new Plane(add);
    plane.color = color;
    out.add(plane);

    add = new ArrayList<Point3D>();
    add.add(lines.get(0).point1);
    add.add(lines.get(0).point2);
    add.add(lines.get(4).point2);
    add.add(lines.get(4).point1);
    plane = new Plane(add);
    plane.color = color;
    out.add(plane);

    add = new ArrayList<Point3D>();
    add.add(lines.get(1).point1);
    add.add(lines.get(1).point2);
    add.add(lines.get(5).point2);
    add.add(lines.get(5).point1);
    plane = new Plane(add);
    plane.color = color;
    out.add(plane);

    add = new ArrayList<Point3D>();
    add.add(lines.get(2).point1);
    add.add(lines.get(2).point2);
    add.add(lines.get(6).point2);
    add.add(lines.get(6).point1);
    plane = new Plane(add);
    plane.color = color;
    out.add(plane);

    add = new ArrayList<Point3D>();
    add.add(lines.get(3).point1);
    add.add(lines.get(3).point2);
    add.add(lines.get(7).point2);
    add.add(lines.get(7).point1);
    plane = new Plane(add);
    plane.color = color;
    out.add(plane);

    return out;
  }
Esempio n. 16
0
  /**
   * Sole constructor
   *
   * @param planetModel is the planet model.
   * @param X is the X value.
   * @param Y is the Y value.
   * @param minZ is the minimum Z value.
   * @param maxZ is the maximum Z value.
   */
  public dXdYZSolid(
      final PlanetModel planetModel,
      final double X,
      final double Y,
      final double minZ,
      final double maxZ) {
    super(planetModel);
    // Argument checking
    if (maxZ - minZ < Vector.MINIMUM_RESOLUTION)
      throw new IllegalArgumentException("Z values in wrong order or identical");

    // Build the planes and intersect them.
    final Plane xPlane = new Plane(xUnitVector, -X);
    final Plane yPlane = new Plane(yUnitVector, -Y);
    final SidedPlane minZPlane = new SidedPlane(0.0, 0.0, maxZ, zUnitVector, -minZ);
    final SidedPlane maxZPlane = new SidedPlane(0.0, 0.0, minZ, zUnitVector, -maxZ);
    surfacePoints = xPlane.findIntersections(planetModel, yPlane, minZPlane, maxZPlane);
  }
 @Override
 public double computeDistance(
     final PlanetModel planetModel,
     final Plane plane,
     final double x,
     final double y,
     final double z,
     final Membership... bounds) {
   return plane.linearDistanceSquared(planetModel, x, y, z, bounds);
 }
Esempio n. 18
0
 @Override
 public int hashCode() {
   int result = super.hashCode();
   result = 31 * result + minXPlane.hashCode();
   result = 31 * result + maxXPlane.hashCode();
   result = 31 * result + yPlane.hashCode();
   result = 31 * result + minZPlane.hashCode();
   result = 31 * result + maxZPlane.hashCode();
   return result;
 }
  /**
   * <code>whichSide</code> takes a plane (typically provided by a view frustum) to determine which
   * side this bound is on.
   *
   * @param plane the plane to check against.
   * @return side
   */
  public Plane.Side whichSide(Plane plane) {
    float distance = plane.pseudoDistance(center);

    if (distance <= -radius) {
      return Plane.Side.Negative;
    } else if (distance >= radius) {
      return Plane.Side.Positive;
    } else {
      return Plane.Side.None;
    }
  }
 //     @Ignore
 @Test
 public void testSideBySide() {
   final int passengers = 121;
   final Plane plane = new EF747("swansea", "scunthorpe", passengers);
   final int capacity = 130;
   final int emptySeats = 9;
   final Vehicle vehicle = new HL777b("SWANSEA-SCUNTHORPE", capacity, emptySeats);
   final Plane adapted = new VehicleAdapter(vehicle);
   assertEquals(plane.getOrigin(), adapted.getOrigin());
   assertEquals(plane.getDestination(), adapted.getDestination());
   assertEquals(plane.getPassengerCount(), adapted.getPassengerCount());
   System.out.println("Side by side test OK");
 }
Esempio n. 21
0
 @Override
 public Polygon construct(
     Polygon out, float x, float y, float z, float width, float height, Plane plane) {
   Vector pos = new Vector(x, y, z);
   for (int i = 0; i < lod; i++) {
     Vector v = plane.map(width * trigs[lod + i], height * trigs[i]);
     v = Vector.add(v, pos, v);
     out.vertices[i] = new Vertex3D(v);
   }
   return out;
 }
Esempio n. 22
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((cancellationInfo == null) ? 0 : cancellationInfo.hashCode());
   result = prime * result + ((date == null) ? 0 : date.hashCode());
   result = prime * result + ((flightID == null) ? 0 : flightID.hashCode());
   result = prime * result + (isCancelled ? 1231 : 1237);
   result = prime * result + (isDiverted ? 1231 : 1237);
   result = prime * result + ((passengers == null) ? 0 : passengers.hashCode());
   result = prime * result + ((plane == null) ? 0 : plane.hashCode());
   return result;
 }
  /** @param args the command line arguments */
  public static void main(String[] args) {
    // RayTracing Variables
    int h = 600;
    int w = 800;
    double[] planeDim = {1., 0, 0, -100};
    double[] eyeDim = {100.5, 0, 0};
    double[] topDim = {100.0, 0.1, 0};
    // Normal Variables
    CameraPlane pl = new CameraPlane(planeDim);
    Point pt = new Point(eyeDim);
    // Create Camera
    cam = new Camera(pl, pt, w, h);
    // Set Camera Frame
    cam.setTopDir(topDim, .001);
    // CreateObjects
    // Sphere
    double[] sDim1 = {0, 0, 0, 400};
    Sphere s1 = new Sphere(sDim1);
    s1.setColor(sphere1);
    s1.setKA(0.1);
    s1.setKD(0.9);
    s1.setKS(1);
    s1.setN(2000);
    double[] sDim2 = {10, 10, -10, 100};
    Sphere s2 = new Sphere(sDim2);
    s2.setColor(sphere2);
    s2.setKA(0.1);
    s2.setKD(0.9);
    s2.setKS(1);
    s2.setN(2000);
    // Plane
    double[] pDim1 = {0, 1, 0, 40};
    Plane p1 = new Plane(pDim1);
    p1.setColor(plane);
    p1.setKA(0.1);
    p1.setKD(0.9);
    p1.setKS(1);
    p1.setN(1000);
    // Lighting
    double[] l1Dim = {200, 200, 200};
    Light l1 = new Light(l1Dim);

    // Main Render Loop
    for (int yR = 0; yR < h; yR++) {
      for (int xR = 0; xR < w; xR++) {
        Ray primary = cam.createRay(xR, yR);
        cam.img.setRGB(xR, yR, trace(primary).getRGB());
      }
    }

    // Output Image
    try {
      File outputfile = new File("saved.png");
      ImageIO.write(cam.img, "png", outputfile);
    } catch (IOException e) {
    }
  }
Esempio n. 24
0
 public void drawPlane(
     int x1,
     int y1,
     int z1,
     int x2,
     int y2,
     int z2,
     int x3,
     int y3,
     int z3,
     int x4,
     int y4,
     int z4) {
   Plane.drawPlane(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);
 }
Esempio n. 25
0
 public void fillPlane(
     int texture,
     int x1,
     int y1,
     int z1,
     int x2,
     int y2,
     int z2,
     int x3,
     int y3,
     int z3,
     int x4,
     int y4,
     int z4) {
   Plane.fillPlane(texture, x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4);
 }
Esempio n. 26
0
 protected String getPlaneInfoText(Plane p) {
   String rs = new String(" ");
   rs += (new Character(p.getIdChar())).toString() + p.alt + " ";
   rs += p.destination.getName() + " ";
   if (p.dir_cmd != null) {
     if (p.dir_cmd instanceof CircleCommand) {
       rs += "C";
     } else {
       rs += ((TurnCommand) p.dir_cmd).dir.getDirName();
     }
     if (p.dir_cmd.pos_obj != null) {
       rs += "@";
       rs += p.dir_cmd.pos_obj.getName();
     }
   }
   return rs;
 }
Esempio n. 27
0
  public void PlaneRemove(Plane p) {
    char id = p.getIdChar();
    UIPlane uiplane = null;
    synchronized (this) {
      uiplane = (UIPlane) (planes.get((Object) (new Character(id))));
    }
    if (uiplane == null) return;

    if (uiplane.radar_label != null) radarArea.remove(uiplane.radar_label);
    if (uiplane.info_label != null) infoArea.remove(uiplane.info_label);
    synchronized (this) {
      planes.remove((Object) (new Character(id)));
    }

    radarArea.repaint();
    infoArea.repaint();
  }
Esempio n. 28
0
  public void PlaneNew(Plane p) {
    if (ATC.debug_flag) System.out.println("p.n.1");
    UIPlane uiplane = new UIPlane();
    char id = p.getIdChar();
    uiplane.radar_label = null;
    uiplane.info_label = new Label((new Character(id)).toString());
    if (ATC.debug_flag) System.out.println("p.n.2");
    infoArea.add(uiplane.info_label);
    if (ATC.debug_flag) System.out.println("p.n.2.1");
    infoArea.validate();
    if (ATC.debug_flag) System.out.println("p.n.3");
    synchronized (this) {
      planes.put((Object) (new Character(id)), (Object) uiplane);
    }

    if (ATC.debug_flag) System.out.println("p.n.4");
    PlaneUpdate(p);
    if (ATC.debug_flag) System.out.println("p.n.5");
  }
Esempio n. 29
0
  private static final boolean isInside(Plane p, AABBox box) {
    final float[] low = box.getLow();
    final float[] high = box.getHigh();
    if (p.distanceTo(low[0], low[1], low[2]) > 0.0f) return (true);
    if (p.distanceTo(high[0], low[1], low[2]) > 0.0f) return (true);
    if (p.distanceTo(low[0], high[1], low[2]) > 0.0f) return (true);
    if (p.distanceTo(high[0], high[1], low[2]) > 0.0f) return (true);
    if (p.distanceTo(low[0], low[1], high[2]) > 0.0f) return (true);
    if (p.distanceTo(high[0], low[1], high[2]) > 0.0f) return (true);
    if (p.distanceTo(low[0], high[1], high[2]) > 0.0f) return (true);
    if (p.distanceTo(high[0], high[1], high[2]) > 0.0f) return (true);

    return (false);
  }
Esempio n. 30
-1
  private synchronized void processNewPlane(NewPlane plane) {
    char id = plane.getEntranceGateId();

    // Verificar se h� "vaga" para um novo avi�o
    if (backBuffer.keySet().size() >= 26) // S� podem haver no m�ximo 26 avi�es
    return;

    // Onde est� a porta?
    int x = board.getPorts().get(id).getxCoord();
    int y = board.getPorts().get(id).getyCoord();

    // Verificar se j� n�o foi adicionado um avi�o aquela porta neste epoch
    /*
    	for(Plane p : backBuffer.values())
    	if(p.getxCoord()==x && p.getyCoord()==y)
    		return;
    */
    if (actualAdds.containsKey(board.getPorts().get(id))) return;

    // Verificar se n�o foi adicionado um avi�o naquela porta com aquela altitude no epoch anterior
    /*
    for(Plane p : frontBuffer.values())
    	if(p.getxCoord()==x && p.getyCoord()==y && p.getAltitude()==plane.getHeight())
    		return;
    */
    if (previousAdds.containsKey(board.getPorts().get(id))) return;

    // OK, bora l� adicionar um avi�o ent�o!
    char id2 = plane.getExitGateID();
    char newID;
    for (newID = 'A'; newID <= 'Z'; newID++) if (!backBuffer.containsKey(newID)) break;

    Plane p =
        new Plane(
            newID,
            board.getPorts().get(id2).clone(),
            plane.getHeightGoal(),
            plane.getHeight(),
            plane.getHeight(),
            x,
            y,
            plane.getDirection(),
            newID,
            1);

    actualAdds.put(board.getPorts().get(id).clone(), p.getAltitude());
    backBuffer.put(newID, p);
  }