Ejemplo n.º 1
0
 private void removeWish() {
   try {
     marketobj.removeWish(command.getItemName(), command.getPrice(), command.getClient());
     contr.updateLog(client.getName() + " removed wish for " + command.getItemName());
     getWishes();
   } catch (RemoteException e) {
     contr.remoteExceptionHandler(e);
   }
 }
Ejemplo n.º 2
0
 private void sell() {
   try {
     marketobj.Sell(command.getItemName(), command.getItemDescr(), command.getPrice(), client);
     contr.updateLog(client.getName() + " listed " + command.getItemName() + " for sale");
     getForSale();
   } catch (RemoteException e) {
     contr.remoteExceptionHandler(e);
   }
 }
Ejemplo n.º 3
0
 private void removeSell() {
   try {
     marketobj.removeSell(
         command.getItemName(), command.getItemDescr(), command.getPrice(), command.getClient());
     contr.updateLog(
         client.getName() + " removed " + command.getItemName() + " that was listed as for sale");
     getForSale();
   } catch (RemoteException e) {
     contr.remoteExceptionHandler(e);
   }
 }
Ejemplo n.º 4
0
 private void logOut() {
   try {
     marketobj.logOut(command.getClient());
   } catch (RemoteException e) {
     contr.remoteExceptionHandler(e);
   }
 }
Ejemplo n.º 5
0
  private void logIn() {

    try {
      if (marketobj.login(client, command.getPassword())) {
        contr.setAccount();
        contr.successfulLogin();
      } else contr.failedLogin();
    } catch (RemoteException e) {
      contr.remoteExceptionHandler(e);
    }
  }
Ejemplo n.º 6
0
 private void register() {
   System.out.println("registering");
   try {
     marketobj.register(client, command.getPassword());
     contr.successfulReg();
     // contr.updateLog(client.getName() + " registered at the marketplace");
   } catch (RejectedException e) {
     contr.failedReg();
   } catch (RemoteException e2) {
     contr.remoteExceptionHandler(e2);
   }
 }
Ejemplo n.º 7
0
 @Override
 protected Boolean doInBackground() throws Exception {
   switch (command.getCommandName()) {
     case buy:
       buy();
       break;
     case sell:
       sell();
       break;
     case register:
       register();
       break;
     case wish:
       wish();
       break;
     case logout:
       logOut();
       break;
     case login:
       logIn();
       break;
     case listItems:
       listItems();
       break;
     case getWishes:
       getWishes();
       break;
     case getForSale:
       getForSale();
       break;
     case removeWish:
       removeWish();
       break;
     case removeSell:
       removeSell();
       break;
     case getSold:
       getSold();
       break;
     case getBought:
       getBought();
       break;
   }
   return true;
 }
Ejemplo n.º 8
0
 private void buy() {
   try {
     marketobj.Buy(
         command.getItemName(),
         command.getItemDescr(),
         command.getPrice(),
         command.getSeller(),
         client);
     contr.updateLog(
         "you bought "
             + command.getItemName()
             + " from "
             + command.getSeller()
             + " for: "
             + command.getPrice());
     listItems();
   } catch (RejectedException e2) {
     contr.rejectedExceptionHandler(e2);
   } catch (RemoteException e) {
     contr.remoteExceptionHandler(e);
   }
 }
Ejemplo n.º 9
0
 public MarketWorker(MarketPlace marketobj, MarketCommand command, GuiController contr) {
   this.client = command.getClient();
   this.marketobj = marketobj;
   this.command = command;
   this.contr = contr;
 }