41cf137204662eddd781057db13f0bc961a8c662
[pcd.git] / src / subastas / Cliente.java
1 package subastas;
2
3 import java.io.BufferedReader;
4 import java.io.FileNotFoundException;
5 import java.io.FileReader;
6 import java.io.IOException;
7 import java.io.InputStreamReader;
8 import java.io.LineNumberReader;
9
10 import org.omg.CORBA.*;
11
12 public class Cliente {
13
14         /**
15          * @param args
16          * @throws IOException 
17          */
18         public static void main(String[] args) throws IOException {
19                 ORB orb = ORB.init(args, null);
20                 
21                 LineNumberReader input = new LineNumberReader(new FileReader("server.ior"));
22                 String ior = input.readLine();
23                 
24                 org.omg.CORBA.Object obj = orb.string_to_object(ior);
25                 
26                 gestorSubastas gs = gestorSubastasHelper.narrow(obj);
27                 
28                 
29                 //usando el objecto gs
30                 coordinadorSubasta cs = gs.crearSubasta((float)10.0, "clip rojo");
31                 System.out.println(cs.valor());
32                 System.out.println(cs.descripcion());
33                 System.out.println(cs.estado());
34
35                 clienteSubastas cl1 = new clienteSubastas("cliente1");
36                 clienteSubastas cl2 = new clienteSubastas("cliente2");
37                 cs.inscribirCliente(cl1);
38                 cs.inscribirCliente(cl2);
39                 
40                 cs.abrirSubasta();
41                 //deberia estar abierto
42                 System.out.println(cs.estado());
43                 cs.pujar(21, cl1);
44                 if(cs.pujar(20, cl2)){
45                         System.out.println(cl2.identificacion() + ": mi puja es más alta");
46                 }
47                 cs.ultimaPuja(cl2);
48                 cs.ultimaPuja(cl1);
49                 System.out.println(cs.ganador().identificacion());
50                 
51                 boolean salir = false;
52                 String comando = "";
53                 while(!salir){
54                         try{
55                                 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
56                                 comando = br.readLine();
57                                 }catch(Exception e){ e.printStackTrace();} 
58                         if(comando.equals("salir")){
59                                 salir = true;
60                                 break;
61                         }
62                         else if(comando.contains("crear")){
63                                 String[] partesDelComando = comando.split(" ");
64                                 for(int i=0; i<partesDelComando.length; i++){
65                                         System.out.println(partesDelComando[i]);
66                                 }
67                         }
68                 }
69         }
70
71 }