コード例 #1
0
ファイル: AssetTrack.java プロジェクト: enisbt/CMPE-261
 public void modifyCar(int id, int price, String name, int model, String color) {
   Car temp = (Car) cars.get(id);
   temp.setPrice(price);
   temp.setName(name);
   temp.setModel(model);
   temp.setColor(color);
   cars.set(id, temp);
 }
コード例 #2
0
 // Returns price of cars at this location
 public ReturnTuple<Integer> queryCarsPrice(int id, String location, Timestamp timestamp)
     throws RemoteException, TransactionAbortedException, InvalidTransactionException {
   if (!isMaster) {
     System.out.println("Slave retransmitting queryCarsPrice to master");
     return this.getMaster().queryCarsPrice(id, location, timestamp);
   } else {
     QueryCarsPriceRMICommand qcp = new QueryCarsPriceRMICommand(roomGroup, id, location);
     qcp.setTimestampObject(timestamp);
     ReturnTuple<Integer> result = null;
     try {
       overseer.validTransaction(id);
       lm.Lock(id, Car.getKey(location), qcp.getRequiredLock());
       qcp.execute();
       result = qcp.price;
     } catch (DeadlockException d) {
       timestamp.stamp();
       overseer.abort(id);
       timestamp.stamp();
       throw new TransactionAbortedException(timestamp);
     } catch (TransactionAbortedException tae) {
       tae.t = timestamp;
       throw tae;
     } catch (InvalidTransactionException ite) {
       ite.t = timestamp;
       throw ite;
     }
     result.timestamp.stamp();
     return result;
   }
 }
コード例 #3
0
 // Delete cars from a location
 public ReturnTuple<Boolean> deleteCars(int id, String location, Timestamp timestamp)
     throws RemoteException, TransactionAbortedException, InvalidTransactionException {
   if (!isMaster) {
     System.out.println("Slave retransmitting deleteCars to master");
     return this.getMaster().deleteCars(id, location, timestamp);
   } else {
     timestamp.stamp();
     DeleteCarsRMICommand dc = new DeleteCarsRMICommand(carGroup, id, location);
     dc.setTimestampObject(timestamp);
     ReturnTuple<Boolean> result = null;
     try {
       overseer.validTransaction(id);
       lm.Lock(id, Car.getKey(location), dc.getRequiredLock());
       dc.execute();
       result = dc.success;
       if (result.result) overseer.addCommandToTransaction(id, dc);
     } catch (DeadlockException d) {
       timestamp.stamp();
       overseer.abort(id);
       timestamp.stamp();
       throw new TransactionAbortedException(timestamp);
     } catch (TransactionAbortedException tae) {
       tae.t = timestamp;
       throw tae;
     } catch (InvalidTransactionException ite) {
       ite.t = timestamp;
       throw ite;
     }
     result.timestamp.stamp();
     return result;
   }
 }
コード例 #4
0
ファイル: AssetTrack.java プロジェクト: enisbt/CMPE-261
 public String printCar() {
   String result = "Cars\nid\t\tprice\t\tname\t\tmodel\t\tcolor\n";
   for (int i = 0; i < cars.size(); i++) {
     Car temp = (Car) cars.get(i);
     result =
         result
             + i
             + "\t\t"
             + temp.getPrice()
             + "\t\t"
             + temp.getName()
             + "\t\t"
             + temp.getModel()
             + "\t\t"
             + temp.getColor()
             + "\n";
   }
   return result;
 }
コード例 #5
0
 // return a bill
 public ReturnTuple<String> queryCustomerInfo(int id, int customerID, Timestamp timestamp)
     throws RemoteException, TransactionAbortedException, InvalidTransactionException {
   if (!isMaster) {
     System.out.println("Slave retransmitting queryCustomerInfo to master");
     return this.getMaster().queryCustomerInfo(id, customerID, timestamp);
   } else {
     timestamp.stamp();
     QueryCustomerInfoRMICommand qci =
         new QueryCustomerInfoRMICommand(carGroup, flightGroup, roomGroup, id, customerID);
     qci.setTimestampObject(timestamp);
     ReturnTuple<String> result = null;
     try {
       Vector<Integer> flightNos;
       Vector<String> locations;
       overseer.validTransaction(id);
       lm.Lock(id, Customer.getKey(customerID), qci.getRequiredLock());
       qci.execute();
       flightNos = qci.getCustomerFlightReservations();
       for (int flightNo : flightNos) {
         lm.Lock(id, Flight.getKey(flightNo), qci.getRequiredLock());
       }
       locations = qci.getCustomerRoomReservations();
       for (String location : locations) {
         lm.Lock(id, Hotel.getKey(location), qci.getRequiredLock());
       }
       locations = qci.getCustomerCarReservations();
       for (String location : locations) {
         lm.Lock(id, Car.getKey(location), qci.getRequiredLock());
       }
       qci.execute();
       result = qci.customerInfo;
     } catch (DeadlockException d) {
       timestamp.stamp();
       overseer.abort(id);
       timestamp.stamp();
       throw new TransactionAbortedException(timestamp);
     } catch (TransactionAbortedException tae) {
       tae.t = timestamp;
       throw tae;
     } catch (InvalidTransactionException ite) {
       ite.t = timestamp;
       throw ite;
     }
     result.timestamp.stamp();
     return result;
   }
 }
コード例 #6
0
 // Create a new car location or add cars to an existing location.
 // Note: if price <= 0 and the car location already exists, it maintains
 // its current price.
 @Override
 public boolean addCars(int id, String location, int numCars, int carPrice) {
   Trace.info(
       "RM::addCars(" + id + ", " + location + ", " + numCars + ", $" + carPrice + ") called.");
   synchronized (syncLock) {
     Car curObj = (Car) readData(id, Car.getKey(location));
     if (curObj == null) {
       // Doesn't exist; add it.
       Car newObj = new Car(location, numCars, carPrice);
       writeData(id, newObj.getKey(), newObj);
       Trace.info(
           "RM::addCars(" + id + ", " + location + ", " + numCars + ", $" + carPrice + ") OK.");
     } else {
       // Add count to existing object and update price.
       curObj.setCount(curObj.getCount() + numCars);
       if (carPrice > 0) {
         curObj.setPrice(carPrice);
       }
       writeData(id, curObj.getKey(), curObj);
       Trace.info(
           "RM::addCars("
               + id
               + ", "
               + location
               + ", "
               + numCars
               + ", $"
               + carPrice
               + ") OK: "
               + "cars = "
               + curObj.getCount()
               + ", price = $"
               + carPrice);
     }
     return (true);
   }
 }
コード例 #7
0
ファイル: CarWorld.java プロジェクト: cbsejpal/minion-runner
  /** Constructor for objects of class CarWorld. */
  public CarWorld() {
    super(600, 600, 1);
    setPaintOrder(
        Start.class,
        Help.class,
        Pause.class,
        Information.class,
        ScoreBoard.class,
        Dot.class,
        Path.class,
        Car.class,
        Bomb.class,
        Vehicle.class,
        Person.class,
        PedestrianCrossing.class,
        EndLine.class,
        Line.class,
        Counter.class,
        Lives.class,
        Background.class);
    // Greenfoot.playSound("minion_theme_01.mp3");

    // Setting background sound resources
    setBackgroundSounds();

    lives = 100;
    score = 0;
    pause = true;
    // changes by Manthan start
    car = new Car();
    car.attachObserver(new CarController(car));
    // Changes by manthan end
    leafs = new ArrayList<Component>();
    add(car, 305, 550);
    add(new Counter("Score: "), 95, 550);
    /*add(new Lives(),50,50);
    add(new Lives(),100,50);
    add(new Lives(),150,50);
    */
    add(new Dot(), 25, 395);
    add(new Path(), 25, 250);

    // Banana score visualization
    add(new BananaScore("Banana Score: "), 150, 580);
    // Weapon Power visualization
    bar.setShowTextualUnits(false);
    addObject(bar, 500, 50);

    // Life visualization
    lifeBar.setShowTextualUnits(false);
    addObject(lifeBar, 70, 50);
    lifeBar.setValue(100);

    /*add(new Line(),300,0);
    add(new Line(),300,90);
    add(new Line(),300,180);
    add(new Line(),300,270);
    add(new Line(),300,360);
    add(new Line(),300,450);
    add(new Line(),300,540);*/
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150), Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    add(new Background(), Greenfoot.getRandomNumber(150) + 450, Greenfoot.getRandomNumber(600));
    //         add(new Information(),300,300);
    add(new Start(), 480, 550);
    add(new Help(), 550, 550);
  }
コード例 #8
0
 // Add car reservation to this customer.
 @Override
 public boolean cancelReserveCar(int id, int customerId, String location) {
   return cancelReserveItem(id, customerId, Car.getKey(location), location);
 }
コード例 #9
0
 // Returns price of cars at this location.
 @Override
 public int queryCarsPrice(int id, String location) {
   return queryPrice(id, Car.getKey(location));
 }
コード例 #10
0
 // Delete cars from a location.
 @Override
 public boolean deleteCars(int id, String location) {
   return deleteItem(id, Car.getKey(location));
 }
コード例 #11
0
  public int compare(Car car1, Car car2) {

    return car2.getPrice() - car1.getPrice();
  }
コード例 #12
0
ファイル: FlightRM.java プロジェクト: sameerjagdale/dsPart2
 // Adds car reservation to this customer.
 public boolean reserveCar(int id, int customerID, String location) throws RemoteException {
   return reserveItem(id, customerID, Car.getKey(location), location);
 }
コード例 #13
0
ファイル: FlightRM.java プロジェクト: sameerjagdale/dsPart2
 // Returns price of cars at this location
 public int queryCarsPrice(int id, String location) throws RemoteException {
   return queryPrice(id, Car.getKey(location));
 }
コード例 #14
0
ファイル: FlightRM.java プロジェクト: sameerjagdale/dsPart2
 // Delete cars from a location
 public boolean deleteCars(int id, String location) throws RemoteException {
   return deleteItem(id, Car.getKey(location));
 }
コード例 #15
0
ファイル: Game.java プロジェクト: worldofanguis/VelociRUPtors
 int setRobberVelocity(int i) {
   me.setTick(i);
   return (me.startSpeed);
 }
コード例 #16
0
ファイル: Game.java プロジェクト: worldofanguis/VelociRUPtors
 void setRobberDirection(Directions dir) {
   me.setDirection(dir.value);
 }