Esempio n. 1
0
  private void onBidClicked() {
    try {
      // Determine which bidder auction is selected
      String auctionName = (String) bidList.getSelectedValue();

      // Determine what the bid is
      int bidPrice = Integer.parseInt(txtBidPrice.getText());

      if (auctionName != null) {
        // resolve the Object Reference in Naming
        Auction auctionImpl = AuctionHelper.narrow(ncRef.resolve_str(auctionName));

        // Place bid
        auctionImpl.bid(userName, bidPrice);
        appletDisplay("Placed bid of $" + Integer.toString(bidPrice) + " on " + auctionName);

        // Update the auction lists
        updateAuctionLists(false);
      }
      ;

    } catch (NumberFormatException e1) {
      appletDisplay("Invalid bid price");
    } catch (AuctionFailure e2) {
      appletDisplay(e2.description);
    } catch (Exception e3) {
      appletDisplay("Unable to place bid");
      System.out.println("ERROR : " + e3);
      e3.printStackTrace(System.out);
    }
  }
Esempio n. 2
0
  private void onSellItemClick() {
    try {
      // Determine which seller auction is selected
      String auctionName = (String) sellList.getSelectedValue();

      if (auctionName != null) {
        // resolve the Object Reference in Naming
        Auction auctionImpl = AuctionHelper.narrow(ncRef.resolve_str(auctionName));

        // Sell item
        auctionImpl.sellItem(userName);
        appletDisplay(auctionName + " has ended");

        // Update the auction lists
        updateAuctionLists(false);
      }
      ;

    } catch (NumberFormatException e1) {
      appletDisplay("Invalid bid price");
    } catch (AuctionFailure e2) {
      appletDisplay(e2.description);
    } catch (Exception e3) {
      appletDisplay("Unable to place bid");
      System.out.println("ERROR : " + e3);
      e3.printStackTrace(System.out);
    }
  }
Esempio n. 3
0
  private void onCreateNewAuctionClicked() {
    try {
      int startingPrice;
      String description = txtDescription.getText();

      if (txtStartingPrice.getText().equals("")) {
        startingPrice = 0;
      } else {
        startingPrice = Integer.parseInt(txtStartingPrice.getText());
      }

      // Get a reference to an inactive auction from the auction manager.
      String auctionRef = auctionFactoryImpl.getInactiveAuction();

      // resolve the Object Reference in Naming
      Auction auctionImpl = AuctionHelper.narrow(ncRef.resolve_str(auctionRef));

      // Put an item up for sale
      auctionImpl.offerItem(userName, description, startingPrice);

      // Update the auction lists
      updateAuctionLists(false);

      appletDisplay("Started new auction");

    } catch (NumberFormatException e1) {
      appletDisplay("Invalid starting price");
    } catch (AuctionFailure e2) {
      appletDisplay(e2.description);
    } catch (Exception e3) {
      appletDisplay("Unable to create a new auction");
      System.out.println("ERROR : " + e3);
      e3.printStackTrace(System.out);
    }
  }
Esempio n. 4
0
  private AuctionStatus getAuctionStatus(String auctionServerName) throws Exception {

    BooleanHolder isActive = new BooleanHolder();
    StringHolder itemDesc = new StringHolder();
    IntHolder price = new IntHolder();
    StringHolder highBidder = new StringHolder();

    // resolve the Object Reference in Naming
    Auction auctionImpl = AuctionHelper.narrow(ncRef.resolve_str(auctionServerName));

    // Get the auction status
    auctionImpl.viewAuctionStatus(userName, isActive, itemDesc, price, highBidder);

    // Return the status
    return new AuctionStatus(isActive.value, itemDesc.value, price.value, highBidder.value);
  }