Package org.glassfish.jersey.examples.flight.model

Examples of org.glassfish.jersey.examples.flight.model.Location


            throw new BadRequestException("Incomplete data.");
        }

        Aircraft aircraft = new Aircraft();
        aircraft.setType(new AircraftType(manufacturer, type, capacity));
        aircraft.setLocation(SimEngine.bound(new Location(x, y)));

        if (!DataStore.addAircraft(aircraft)) {
            throw new InternalServerErrorException("Unable to add new aircraft.");
        }
View Full Code Here


        return aircraft;
    }

    public static Location generateLocation(int xBound, int yBound) {
        return new Location(
                rnd.nextInt(xBound), rnd.nextInt(yBound));
    }
View Full Code Here

            y = y % Y_BOUND;
        } else if (y < 0) {
            y = Y_BOUND + (y % Y_BOUND);
        }
        return (x != location.getX() || y != location.getY())
                ? new Location(x, y) : location;
    }
View Full Code Here

            final int boundSpeedX = X_BOUND / 30;
            final int boundSpeedY = Y_BOUND / 30;
            final int count = 0;
            for (final Flight flight : flights) {
                flight.setStatus(Flight.Status.CLOSED);
                final Location vector = DataStore.generateLocation(boundSpeedX, boundSpeedY);
                switch (count / 4) {
                    case 0:
                        vector.setX(-vector.getX());
                        break;
                    case 1:
                        vector.setY(-vector.getY());
                        break;
                    case 2:
                        vector.setX(-vector.getX());
                        vector.setY(-vector.getY());
                        break;
                    case 3:
                        // no change
                        break;
                }
View Full Code Here

                    cleanup();
                    return;
                }

                final Flight flight = flights.get(i);
                final Location vector = vectors.get(i);
                Location newLocation = new Location(
                        flight.getAircraft().getLocation().getX() + vector.getX(),
                        flight.getAircraft().getLocation().getY() + vector.getY()
                );
                newLocation = bound(newLocation);
                flight.getAircraft().setLocation(newLocation);
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.examples.flight.model.Location

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.