/* * 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 . */ package utils; import java.io.Serializable; import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; import java.util.Date; /** * Die Klasse erzeugt die Message-Objekte * @version 0.0.2 * @author berdan */ /** * * @author berda */ public class Message implements Serializable { private String username; private String message; private String time = "00:00"; /** * Konstruktor des Message Objektes * * @param username Der Benutzername, welcher gewählt wurde * @param message Die Nachricht, welche geschrieben wurde * */ public Message(String username, String message) { this.username = username; this.message = message; this.time = new SimpleDateFormat("HH.mm.ss").format(new Date()); } /** * toString Methode * @return Ein String, welcher die Informationen der Nachricht ausgibt */ @Override public String toString() { return "nickname=" + username + ", message=" + message + ", time =" + time; //+ ", time=" + date; } /** * Funktion gibt false aus, sobald der Text der Nachricht "exit" ist * @return Einen Boolean, welcher false ausgibt, fals die Nachricht exit ist */ public boolean exit() { return !message.equalsIgnoreCase("exit"); } /** * Funktion, welche die Nachricht des Message Objektes zurück gibt * @return String, der die Nachricht enthält */ public String getMessage() { return message; } /** * Funktion, welche den Usernamen des Message Objektes zurück gibt * @return String, welcher den Nutzernamen enthält */ public String getUsername() { return username; } /** * * @return String, welcher den Absendezeitpunkt enthält */ public String getTime(){ return time; } }