Strumenti Utente

Strumenti Sito


lpr-b:battitoreasta
no way to compare when less than two revisions

Differenze

Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.


lpr-b:battitoreasta [07/12/2007 alle 09:55 (18 anni fa)] (versione attuale) – creata Marco Danelutto
Linea 1: Linea 1:
 +<code java>
 +package astaRMI;
  
 +import java.rmi.RemoteException;
 +import java.rmi.server.UnicastRemoteObject;
 +import java.util.HashMap;
 +import java.util.Iterator;
 +
 +public class Battitore extends UnicastRemoteObject implements InterfacciaBattitore   {
 +
 + protected Battitore() throws RemoteException {
 + super();
 + }
 +
 + private static final long serialVersionUID = -8624867101274666805L;
 +
 + int offertaCorrente = 0; 
 + String vincitore = ""; 
 + HashMap<String,ClientInterface> clienti = new HashMap<String,ClientInterface>();
 +
 + public synchronized int offer(String name, int howMuch) throws RemoteException {
 + System.out.println("Ricevuta offerta "+howMuch+" da "+name);
 + if(howMuch > offertaCorrente) 
 + {
 + offertaCorrente = howMuch;
 + vincitore = name;
 + System.out.println("Il vincitore ora è "+vincitore+" che ha offerto "+offertaCorrente);
 + Iterator<ClientInterface> it = clienti.values().iterator();
 + while(it.hasNext()) {
 + ClientInterface ci = (ClientInterface) it.next();
 + ci.offer(offertaCorrente);
 + }
 + }
 + return offertaCorrente;
 + }
 +
 + public void register(String name, ClientInterface cif) throws RemoteException {
 + System.out.println("Registrato "+name);
 + clienti.put(name, cif);
 + return;
 + }
 +
 +}
 +</code>
lpr-b/battitoreasta.txt · Ultima modifica: 07/12/2007 alle 09:55 (18 anni fa) da Marco Danelutto

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki