-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserInterface.java
58 lines (51 loc) · 1.53 KB
/
UserInterface.java
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
/**
* Write a description of class UserInterface here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class UserInterface
{
// instance variables - replace the example below with your own
public static void main(String args[])
{
public void log(String s)
{
System.out.println(s);
}
}
FitnessUM fitnessUM = new FitnessUM();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String response = br.readLine();
while(response.equals("exit")==false){
String[] command = response.split(" ");
switch (command[0]){
case "login":
if(command.size()==3){
if(fitnessUM.getUtilizadorLigado()==null){
String username = command[1];
String pass = command[2];
boolean aux = fitnessUM.checkUser(username,pass);
if(aux==false){
log("Dados incorrectos!\n");
}
else
log("Logado com sucesso!\n");
}
}
case "registar":
if (command.size()==3)
{
boolean aux = fitnessUM.registar(command[1],command[2]);
if(aux == true)
{
log("Registado com sucesso!\n");
}
else
log("O registo falhou\n");
}
}
response = br.readLine();
}
}
}