-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClienteLoja.java
More file actions
58 lines (49 loc) · 1.47 KB
/
Copy pathClienteLoja.java
File metadata and controls
58 lines (49 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
public class ClienteLoja {
public static void main (String args[]) {
try {
LojaRemota loja = (LojaRemota)Naming.lookup("rmi://localhost:2126/loja");
LojaRemota loja2 = (LojaRemota)Naming.lookup("rmi://localhost:2127/loja");
loja.inserirProduto("Banana",10);
loja.inserirProduto("Maca",24);
loja.inserirProduto("Goiaba",5);
loja2.inserirProduto("Mamao",40);
loja2.inserirProduto("Maca",25);
loja2.inserirProduto("Laranja",3);
loja2.inserirProduto("Banana",8);
try {
loja.alterarPreco("banana", 10);
} catch (Excecao e2) {
// TODO Auto-generated catch block
System.out.println(e2.getMessage());
}
try {
loja.removerProduto("roupa");
} catch (Excecao e1) {
// TODO Auto-generated catch block
System.out.println(e1.getMessage());
}
try {
loja.removerProduto("bala");
} catch (Excecao e1) {
// TODO Auto-generated catch block
System.out.println(e1.getMessage());
}
try {
System.out.println(loja.procurarProduto("banana").getPreco());
System.out.println(loja.procurarProduto("bala").getPreco());
} catch (Excecao e) {
System.out.println(e.getMessage());
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (NotBoundException e) {
e.printStackTrace();
}
}
}