Added some finishing touches to the Message classes. Integrated some event support in input handling.
40 lines
897 B
Java
40 lines
897 B
Java
package elements;
|
|
|
|
import elements.exceptions.ReadErrorListException;
|
|
|
|
/**
|
|
* Created by Guillermo Serrahima on 10/9/16.
|
|
*/
|
|
public class ChatListItem {
|
|
private String name;
|
|
private Integer value;
|
|
|
|
private ChatListItem() {
|
|
|
|
}
|
|
|
|
public ChatListItem(String name, int value) {
|
|
this.name = name;
|
|
this.value = value;
|
|
}
|
|
|
|
public ChatListItem(String parse) throws ReadErrorListException {
|
|
String[] reading = parse.split(";");
|
|
if(reading.length > 2) throw new ReadErrorListException("Unidentified item.");
|
|
this.name = reading[0];
|
|
this.value = Integer.parseInt(reading[1]);
|
|
}
|
|
|
|
public int compareTo(ChatListItem c) {
|
|
return name.compareTo(c.name);
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return name + ": " + value;
|
|
}
|
|
|
|
public String saveItem() {
|
|
return name + ";" + value;
|
|
}
|
|
}
|