"fin seance 23-09"
This commit is contained in:
parent
53fbb5340a
commit
5ad90deb63
70
2020-2021/src/TD2/Canal.java
Executable file
70
2020-2021/src/TD2/Canal.java
Executable file
@ -0,0 +1,70 @@
|
||||
package TD2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Canal {
|
||||
|
||||
private int maxMessage;
|
||||
private String nomCanal;
|
||||
private Forum forum;
|
||||
private List<Message> lmsg = new ArrayList<Message>();
|
||||
|
||||
public Canal(String nc, int mm) {
|
||||
this.setNomCanal(nc);
|
||||
this.setMaxMessage(mm);
|
||||
}
|
||||
|
||||
public Canal(String nc) {
|
||||
this(nc, 1000);
|
||||
}
|
||||
|
||||
public void addMessage(Message m) {
|
||||
this.getLmsg().add(m);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maxMessage
|
||||
*/
|
||||
public int getMaxMessage() {
|
||||
return maxMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param maxMessage the maxMessage to set
|
||||
*/
|
||||
public void setMaxMessage(int maxMessage) {
|
||||
this.maxMessage = maxMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the nomCanal
|
||||
*/
|
||||
public String getNomCanal() {
|
||||
return nomCanal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nomCanal the nomCanal to set
|
||||
*/
|
||||
public void setNomCanal(String nomCanal) {
|
||||
this.nomCanal = nomCanal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lmsg
|
||||
*/
|
||||
public List<Message> getLmsg() {
|
||||
return lmsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lmsg the lmsg to set
|
||||
*/
|
||||
public void setLmsg(List<Message> lmsg) {
|
||||
this.lmsg = lmsg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -11,7 +11,7 @@ public class Forum {
|
||||
private MessageManager mg;
|
||||
private ForumManager fm;
|
||||
private List<Member> member = new ArrayList<Member>();
|
||||
private List<Message> lmsg = new ArrayList<Message>();
|
||||
private List<Canal> canaux = new ArrayList<Canal>();
|
||||
|
||||
|
||||
public Forum(String n) {
|
||||
@ -27,8 +27,8 @@ public class Forum {
|
||||
return this.getMessageManager().createMessage(content, auth);
|
||||
}
|
||||
|
||||
public void addMessage(Message msg) {
|
||||
this.lmsg.add(msg);
|
||||
public void addMessage(Message msg, String nomCanal) {
|
||||
this.getCanaux().get(getCanalId(nomCanal)).addMessage(msg);
|
||||
}
|
||||
|
||||
public void createUser(String i) {
|
||||
@ -77,17 +77,14 @@ public class Forum {
|
||||
this.nom = nom;
|
||||
}
|
||||
|
||||
public List<Message> getLmsg() {
|
||||
return this.lmsg;
|
||||
}
|
||||
|
||||
public List<Message> getLatestmsg(Member m) {
|
||||
public List<Message> getLatestmsg(Member m, String canalName) {
|
||||
List<Message> l = new ArrayList<Message>();
|
||||
for (Message msg : this.getLmsg()) {
|
||||
if(msg.getCreationDate().compareTo(Date.from(Instant.now() )) <= 10) {
|
||||
l.add(msg);
|
||||
for (Message msg : this.getCanaux().get(getCanalId(canalName)).getLmsg()) {
|
||||
if(msg.getCreationDate().compareTo(Date.from(Instant.now() )) <= 10) {
|
||||
l.add(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
m.lireMessage(l);
|
||||
return l;
|
||||
}
|
||||
@ -137,4 +134,28 @@ public class Forum {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getCanalId(String nomCanal) {
|
||||
int index = -1;
|
||||
for(int i = 0; i < this.getCanaux().size(); i++) {
|
||||
if(this.getCanaux().get(i).getNomCanal().equalsIgnoreCase(nomCanal)) {
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the canal
|
||||
*/
|
||||
public List<Canal> getCanaux() {
|
||||
return canaux;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param canaux the canal to set
|
||||
*/
|
||||
public void setCanaux(List<Canal> canaux) {
|
||||
this.canaux = canaux;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
package TD2;
|
||||
|
||||
public class Internaute {
|
||||
|
||||
private String nom;
|
||||
|
||||
public Internaute(String n) {
|
||||
this.nom = n;
|
||||
}
|
||||
|
||||
public String getNom() {
|
||||
return this.nom;
|
||||
}
|
||||
}
|
187
2020-2021/src/TD2/TD2.ucls
Normal file
187
2020-2021/src/TD2/TD2.ucls
Normal file
@ -0,0 +1,187 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<class-diagram version="1.2.4" icons="true" always-add-relationships="false" generalizations="true" realizations="true"
|
||||
associations="true" dependencies="false" nesting-relationships="true" router="FAN">
|
||||
<class id="1" language="java" name="TD2.Member" project="M315" file="/M315/src/TD2/Member.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="599" y="996"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="true" package="true" protected="true" private="true" static="true"/>
|
||||
<operations public="true" package="true" protected="true" private="true" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="2" language="java" name="TD2.Forum" project="M315" file="/M315/src/TD2/Forum.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="525" y="259"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="true" package="true" protected="true" private="true" static="true"/>
|
||||
<operations public="true" package="true" protected="true" private="true" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="3" language="java" name="TD2.Admin" project="M315" file="/M315/src/TD2/Admin.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="143" y="547"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="true" package="true" protected="true" private="true" static="true"/>
|
||||
<operations public="true" package="true" protected="true" private="true" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="4" language="java" name="TD2.Message" project="M315" file="/M315/src/TD2/Message.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="190" y="997"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="true" package="true" protected="true" private="true" static="true"/>
|
||||
<operations public="true" package="true" protected="true" private="true" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="5" language="java" name="TD2.MessageManager" project="M315" file="/M315/src/TD2/MessageManager.java"
|
||||
binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="609" y="692"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="true" package="true" protected="true" private="true" static="true"/>
|
||||
<operations public="true" package="true" protected="true" private="true" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="6" language="java" name="TD2.ForumManager" project="M315" file="/M315/src/TD2/ForumManager.java"
|
||||
binary="false" corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="858" y="667"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="true" package="true" protected="true" private="true" static="true"/>
|
||||
<operations public="true" package="true" protected="true" private="true" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<class id="7" language="java" name="TD2.Canal" project="M315" file="/M315/src/TD2/Canal.java" binary="false"
|
||||
corner="BOTTOM_RIGHT">
|
||||
<position height="-1" width="-1" x="351" y="674"/>
|
||||
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="true" package="true" protected="true" private="true" static="true"/>
|
||||
<operations public="true" package="true" protected="true" private="true" static="true"/>
|
||||
</display>
|
||||
</class>
|
||||
<association id="8">
|
||||
<end type="SOURCE" refId="4" navigable="false">
|
||||
<attribute id="9" name="author">
|
||||
<position height="0" width="0" x="-97" y="-84"/>
|
||||
</attribute>
|
||||
<multiplicity id="10" minimum="0" maximum="1">
|
||||
<position height="0" width="0" x="-97" y="-84"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="1" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="11">
|
||||
<end type="SOURCE" refId="2" navigable="false">
|
||||
<attribute id="12" name="admin">
|
||||
<position height="0" width="0" x="0" y="0"/>
|
||||
</attribute>
|
||||
<multiplicity id="13" minimum="0" maximum="1">
|
||||
<position height="0" width="0" x="0" y="0"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="3" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="14">
|
||||
<end type="SOURCE" refId="2" navigable="false">
|
||||
<attribute id="15" name="mg">
|
||||
<position height="0" width="0" x="-7" y="-58"/>
|
||||
</attribute>
|
||||
<multiplicity id="16" minimum="0" maximum="1">
|
||||
<position height="0" width="0" x="-7" y="-58"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="5" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="17">
|
||||
<end type="SOURCE" refId="3" navigable="false">
|
||||
<attribute id="18" name="forum">
|
||||
<position height="0" width="0" x="0" y="0"/>
|
||||
</attribute>
|
||||
<multiplicity id="19" minimum="0" maximum="1">
|
||||
<position height="0" width="0" x="0" y="0"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="2" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="20">
|
||||
<end type="SOURCE" refId="7" navigable="false">
|
||||
<attribute id="21" name="lmsg"/>
|
||||
<multiplicity id="22" minimum="0" maximum="2147483647"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="4" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="23">
|
||||
<bendpoint x="977" y="547"/>
|
||||
<bendpoint x="977" y="846"/>
|
||||
<end type="SOURCE" refId="2" navigable="false">
|
||||
<attribute id="24" name="member">
|
||||
<position height="0" width="0" x="-97" y="-84"/>
|
||||
</attribute>
|
||||
<multiplicity id="25" minimum="0" maximum="2147483647">
|
||||
<position height="0" width="0" x="-97" y="-84"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="1" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="26">
|
||||
<end type="SOURCE" refId="2" navigable="false">
|
||||
<attribute id="27" name="canaux"/>
|
||||
<multiplicity id="28" minimum="0" maximum="2147483647"/>
|
||||
</end>
|
||||
<end type="TARGET" refId="7" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="29">
|
||||
<end type="SOURCE" refId="2" navigable="false">
|
||||
<attribute id="30" name="fm">
|
||||
<position height="0" width="0" x="0" y="0"/>
|
||||
</attribute>
|
||||
<multiplicity id="31" minimum="0" maximum="1">
|
||||
<position height="0" width="0" x="0" y="0"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="6" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="32">
|
||||
<end type="SOURCE" refId="1" navigable="false">
|
||||
<attribute id="33" name="msg">
|
||||
<position height="0" width="0" x="-197" y="-90"/>
|
||||
</attribute>
|
||||
<multiplicity id="34" minimum="0" maximum="2147483647">
|
||||
<position height="0" width="0" x="-197" y="-90"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="4" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<association id="35">
|
||||
<end type="SOURCE" refId="6" navigable="false">
|
||||
<attribute id="36" name="l">
|
||||
<position height="0" width="0" x="0" y="0"/>
|
||||
</attribute>
|
||||
<multiplicity id="37" minimum="0" maximum="2147483647">
|
||||
<position height="0" width="0" x="0" y="0"/>
|
||||
</multiplicity>
|
||||
</end>
|
||||
<end type="TARGET" refId="2" navigable="true"/>
|
||||
<display labels="true" multiplicity="true"/>
|
||||
</association>
|
||||
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
|
||||
sort-features="false" accessors="true" visibility="true">
|
||||
<attributes public="true" package="true" protected="true" private="true" static="true"/>
|
||||
<operations public="true" package="true" protected="true" private="true" static="true"/>
|
||||
</classifier-display>
|
||||
<association-display labels="true" multiplicity="true"/>
|
||||
</class-diagram>
|
@ -1,7 +1,6 @@
|
||||
package TD2;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@ -31,7 +30,10 @@ class ForumTest {
|
||||
Admin stade = new Admin("oogle-stade", fm.createForum("OGCN"));
|
||||
stade.getForum().setFm(fm);
|
||||
stade.getForum().createUser("unPseudo");
|
||||
}
|
||||
|
||||
@Test
|
||||
void forumHasCanal() throws InterruptedException {
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user