This commit is contained in:
Lorenzo Iovino 2017-06-29 22:30:39 +02:00
parent 429eb1cb02
commit 5512f1a358
52 changed files with 5537 additions and 1557 deletions

View file

@ -24,8 +24,10 @@ public class Message implements Serializable {
@Override
public String toString(){
String dataToString = "";
for(int i = 0; i< data.size(); i++){
dataToString += data.get(i)+"|";
if(data!=null) {
for (int i = 0; i < data.size(); i++) {
dataToString += data.get(i) + "|";
}
}
return "MESSAGE?sender="+sender+"&token="+token+"&message="+message+"&"+dataToString;
}
@ -53,8 +55,15 @@ public class Message implements Serializable {
String[] dataArray = dataString.split((Pattern.quote("|")));
DefaultListModel<String> dataList = new DefaultListModel<String>();
for (int i = 0; i<dataArray.length; i++){
dataList.addElement(dataArray[i]);
if(!dataArray[i].equals("")) {
dataList.addElement(dataArray[i]);
}
}
if(dataList.size() == 1 && dataList.firstElement().equals("")){
dataList = null;
}
return new Message(message,sender,token,dataList);

View file

@ -4,11 +4,13 @@ package models;
* Created by loke on 17/06/2017.
*/
public class Session {
public String userName;
public String token;
public Session(String userName, String token){
this.userName = userName;
public String token;
public User account;
public Session(User account, String token){
this.token = token;
this.account = account;
}
}

View file

@ -9,9 +9,10 @@ public class User {
public String password;
public Integer score = 0;
public User(String userName, String password){
public User(String userName, String password, Integer score){
this.userName = userName;
this.password = password;
this.score = score;
}
public void addScore(Integer score){