2021-05-18 07:41:37 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 berdan
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2021-05-13 19:09:10 +00:00
|
|
|
package utils;
|
2021-05-13 17:45:54 +00:00
|
|
|
|
|
|
|
import java.io.Serializable;
|
2021-05-15 14:47:52 +00:00
|
|
|
import java.text.SimpleDateFormat;
|
2021-05-13 17:45:54 +00:00
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.time.format.FormatStyle;
|
2021-05-15 14:47:52 +00:00
|
|
|
import java.util.Date;
|
2021-05-13 17:45:54 +00:00
|
|
|
|
2021-05-16 19:13:01 +00:00
|
|
|
/**
|
|
|
|
* Die Klasse erzeugt die Message-Objekte
|
|
|
|
* @version 0.0.2
|
|
|
|
* @author berdan
|
|
|
|
*/
|
2021-05-16 11:32:06 +00:00
|
|
|
|
|
|
|
|
2021-05-17 20:54:18 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author berda
|
|
|
|
*/
|
2021-05-13 19:09:10 +00:00
|
|
|
public class Message implements Serializable {
|
|
|
|
|
2021-05-17 20:54:18 +00:00
|
|
|
private String username;
|
|
|
|
private String message;
|
|
|
|
private String time = "00:00";
|
2021-05-16 19:13:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Konstruktor des Message Objektes
|
|
|
|
*
|
2021-05-17 20:54:18 +00:00
|
|
|
* @param username Der Benutzername, welcher gewählt wurde
|
|
|
|
* @param message Die Nachricht, welche geschrieben wurde
|
2021-05-16 19:13:01 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-05-13 19:09:10 +00:00
|
|
|
public Message(String username, String message) {
|
2021-05-13 17:45:54 +00:00
|
|
|
this.username = username;
|
|
|
|
this.message = message;
|
2021-05-15 14:47:52 +00:00
|
|
|
this.time = new SimpleDateFormat("HH.mm.ss").format(new Date());
|
2021-05-13 17:45:54 +00:00
|
|
|
}
|
2021-05-15 14:47:52 +00:00
|
|
|
|
2021-05-16 19:13:01 +00:00
|
|
|
/**
|
|
|
|
* toString Methode
|
2021-05-17 20:54:18 +00:00
|
|
|
* @return Ein String, welcher die Informationen der Nachricht ausgibt
|
2021-05-16 19:13:01 +00:00
|
|
|
*/
|
2021-05-13 17:45:54 +00:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
2021-05-13 19:09:10 +00:00
|
|
|
return "nickname=" + username
|
2021-05-15 14:47:52 +00:00
|
|
|
+ ", message=" + message
|
|
|
|
+ ", time =" + time;
|
2021-05-14 15:44:48 +00:00
|
|
|
//+ ", time=" + date;
|
2021-05-13 17:45:54 +00:00
|
|
|
}
|
2021-05-15 14:47:52 +00:00
|
|
|
|
2021-05-16 19:13:01 +00:00
|
|
|
/**
|
|
|
|
* Funktion gibt false aus, sobald der Text der Nachricht "exit" ist
|
2021-05-17 20:54:18 +00:00
|
|
|
* @return Einen Boolean, welcher false ausgibt, fals die Nachricht exit ist
|
2021-05-16 19:13:01 +00:00
|
|
|
*/
|
|
|
|
public boolean exit() {
|
|
|
|
return !message.equalsIgnoreCase("exit");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Funktion, welche die Nachricht des Message Objektes zurück gibt
|
2021-05-17 20:54:18 +00:00
|
|
|
* @return String, der die Nachricht enthält
|
2021-05-16 19:13:01 +00:00
|
|
|
*/
|
|
|
|
public String getMessage() {
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Funktion, welche den Usernamen des Message Objektes zurück gibt
|
2021-05-17 20:54:18 +00:00
|
|
|
* @return String, welcher den Nutzernamen enthält
|
2021-05-16 19:13:01 +00:00
|
|
|
*/
|
|
|
|
public String getUsername() {
|
|
|
|
return username;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2021-05-17 20:54:18 +00:00
|
|
|
* @return String, welcher den Absendezeitpunkt enthält
|
2021-05-16 19:13:01 +00:00
|
|
|
*/
|
|
|
|
public String getTime(){
|
|
|
|
return time;
|
|
|
|
}
|
2021-05-15 14:47:52 +00:00
|
|
|
}
|