implemente Grupp Chat Room to User
parent
c0b9b33eba
commit
e14f94dfff
|
@ -7,7 +7,6 @@ import java.util.List;
|
|||
public class ChatRoom {
|
||||
private static int nextRoomId = 1000;
|
||||
private int roomId;
|
||||
private String roomName;
|
||||
private List<Message> messages;
|
||||
private final LocalDateTime createdAt;
|
||||
private User user1;
|
||||
|
@ -20,9 +19,6 @@ public class ChatRoom {
|
|||
this.user1 = user1;
|
||||
this.user2 = user2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void addMessage(Message message) {
|
||||
if (messages == null)
|
||||
messages = new ArrayList<>();
|
||||
|
|
|
@ -1,5 +1,37 @@
|
|||
package domain;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GruppenRoom {
|
||||
private User creater;
|
||||
private List<User> roots;
|
||||
private List<User> participants;
|
||||
private String description;
|
||||
private String name;
|
||||
private List<Message> messages;
|
||||
private final LocalDateTime createdAt;
|
||||
|
||||
public GruppenRoom(User creater, String description, String name) {
|
||||
super();
|
||||
this.creater = creater;
|
||||
this.description = description;
|
||||
this.name = name;
|
||||
this.createdAt = LocalDateTime.now();
|
||||
|
||||
this.roots = new ArrayList<>();
|
||||
this.participants = new ArrayList<>();
|
||||
this.messages = new ArrayList<>();
|
||||
|
||||
this.roots.add(creater);
|
||||
this.participants.add(creater);
|
||||
}
|
||||
|
||||
public boolean addparticipants(User user) {
|
||||
return participants.add(user);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public class User {
|
|||
private UserInfo userInfo;
|
||||
private UserContacts userContacts;
|
||||
private UserChatRoom chatRoom;
|
||||
private List<GruppenRoom> userGruppen;
|
||||
private UserGruppenRoom gruppenRoom;
|
||||
|
||||
public User(String username) {
|
||||
this.userId = nextUserId++;
|
||||
|
@ -19,6 +19,7 @@ public class User {
|
|||
this.userInfo = UserInfo.VERFÜGBAR;
|
||||
this.userContacts = new UserContacts();
|
||||
this.chatRoom = new UserChatRoom();
|
||||
this.gruppenRoom = new UserGruppenRoom();
|
||||
|
||||
}
|
||||
|
||||
|
@ -54,6 +55,10 @@ public class User {
|
|||
return chatRoom;
|
||||
}
|
||||
|
||||
public UserGruppenRoom getUserGruppenRoom() {
|
||||
return gruppenRoom;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User [userId=" + userId + ", username=" + username + ", isOnline=" + isOnline + ", userInfo=" + userInfo
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package domain;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class UserGruppenRoom {
|
||||
private List<GruppenRoom> gruppenRooms;
|
||||
|
||||
public UserGruppenRoom() {
|
||||
this.gruppenRooms = new ArrayList<>();
|
||||
}
|
||||
|
||||
public boolean addGroupproom(GruppenRoom gruppenRoom) {
|
||||
return gruppenRooms.add(gruppenRoom);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue