lpr-b:clienteasta
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:clienteasta [07/12/2007 alle 09:55 (18 anni fa)] (versione attuale) – creata Marco Danelutto | ||
|---|---|---|---|
| Linea 1: | Linea 1: | ||
| + | <code java> | ||
| + | package astaRMI; | ||
| + | import java.io.BufferedReader; | ||
| + | import java.io.IOException; | ||
| + | import java.io.InputStreamReader; | ||
| + | import java.net.MalformedURLException; | ||
| + | import java.rmi.Naming; | ||
| + | import java.rmi.NotBoundException; | ||
| + | import java.rmi.RMISecurityManager; | ||
| + | import java.rmi.RemoteException; | ||
| + | import java.rmi.server.UnicastRemoteObject; | ||
| + | |||
| + | public class Client implements ClientInterface { | ||
| + | |||
| + | public void offer(int howMuch) throws RemoteException { | ||
| + | System.out.println(" | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * @param args | ||
| + | */ | ||
| + | public static void main(String[] args) { | ||
| + | |||
| + | if(args.length==0) { | ||
| + | System.out.println(" | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | // | ||
| + | // | ||
| + | |||
| + | Client c = new Client(); | ||
| + | ClientInterface ci = null; | ||
| + | try { | ||
| + | ci = ((ClientInterface) UnicastRemoteObject.exportObject(c)); | ||
| + | } catch (RemoteException e) { | ||
| + | e.printStackTrace(); | ||
| + | } | ||
| + | InterfacciaBattitore ib = null; | ||
| + | try { | ||
| + | ib = (InterfacciaBattitore) Naming.lookup(" | ||
| + | } catch (MalformedURLException e) { | ||
| + | e.printStackTrace(); | ||
| + | } catch (RemoteException e) { | ||
| + | e.printStackTrace(); | ||
| + | } catch (NotBoundException e) { | ||
| + | e.printStackTrace(); | ||
| + | } | ||
| + | try { | ||
| + | ib.register(args[0], | ||
| + | } catch (RemoteException e) { | ||
| + | e.printStackTrace(); | ||
| + | } | ||
| + | int offerta = 0; | ||
| + | int current = 0; | ||
| + | do { | ||
| + | try { | ||
| + | offerta = (int) (Math.random() * 100.0); | ||
| + | current = ib.offer(args[0], | ||
| + | } catch (RemoteException e) { | ||
| + | e.printStackTrace(); | ||
| + | } | ||
| + | } while(current > offerta); | ||
| + | // Adesso offri di più solo se lo dice l' | ||
| + | BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
| + | do { | ||
| + | String line = null; | ||
| + | try { | ||
| + | line = br.readLine(); | ||
| + | } catch (IOException e) { | ||
| + | e.printStackTrace(); | ||
| + | } | ||
| + | int off = Integer.parseInt(line); | ||
| + | try { | ||
| + | ib.offer(args[0], | ||
| + | } catch (RemoteException e) { | ||
| + | e.printStackTrace(); | ||
| + | } | ||
| + | } while(true); | ||
| + | |||
| + | } | ||
| + | |||
| + | } | ||
| + | </ | ||
lpr-b/clienteasta.txt · Ultima modifica: 07/12/2007 alle 09:55 (18 anni fa) da Marco Danelutto
