Updated 'RankingResponseMessage' class.
Updated the 'RankingResponseMessage' class by removing the 'startingPlayerId' attribute and its getter method from it. In Addition the 'rankingResults' attribute and its getter method were added.
This commit is contained in:
		@@ -2,37 +2,45 @@
 | 
			
		||||
 | 
			
		||||
import com.jme3.network.serializing.Serializable;
 | 
			
		||||
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A message sent by the server to all client to inform them about the current ranking. (only in DetermineStartPlayer)
 | 
			
		||||
 */
 | 
			
		||||
@Serializable
 | 
			
		||||
public class RankingResponseMessage extends ServerMessage {
 | 
			
		||||
 | 
			
		||||
    private final int startingPlayerId;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a new RankingResponse instance.
 | 
			
		||||
     * Create RankingResponseMessage attributes.
 | 
			
		||||
     */
 | 
			
		||||
    public RankingResponseMessage(int startingPlayerId) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.startingPlayerId = startingPlayerId;
 | 
			
		||||
    }
 | 
			
		||||
    private final Map<Integer, Integer> rankingResults;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Constructs a new RankingResponse instance.
 | 
			
		||||
     * Constructor.
 | 
			
		||||
     */
 | 
			
		||||
    public RankingResponseMessage() {
 | 
			
		||||
        super();
 | 
			
		||||
        this.startingPlayerId = 0;
 | 
			
		||||
        this.rankingResults = new HashMap<Integer, Integer>();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The id of the starting Player.
 | 
			
		||||
     * Constructor.
 | 
			
		||||
     *
 | 
			
		||||
     * @return the id of the starting player as an int
 | 
			
		||||
     * @param rankingResults as the results of all players after the start player was determined as a Map combining
 | 
			
		||||
     *                       Integers and Integers.
 | 
			
		||||
     */
 | 
			
		||||
    public int getStartingPlayerId() {
 | 
			
		||||
        return startingPlayerId;
 | 
			
		||||
    public RankingResponseMessage(Map<Integer, Integer> rankingResults) {
 | 
			
		||||
        super();
 | 
			
		||||
        this.rankingResults = rankingResults;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This method will be used to return rankingResults attribute of RankingResponseMessage class.
 | 
			
		||||
     *
 | 
			
		||||
     * @return rankingResults as a Map combining Integers and Integers.
 | 
			
		||||
     */
 | 
			
		||||
    public Map<Integer, Integer> getRankingResults() {
 | 
			
		||||
        return this.rankingResults;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -52,6 +60,14 @@ public void accept(ServerInterpreter interpreter) {
 | 
			
		||||
     */
 | 
			
		||||
    @Override
 | 
			
		||||
    public String toString() {
 | 
			
		||||
        return "RankingResponseMessage{" + "startingPlayerId=" + startingPlayerId + '}';
 | 
			
		||||
        StringBuilder stringBuilder = new StringBuilder();
 | 
			
		||||
        stringBuilder.append("RankingResponseMessage{");
 | 
			
		||||
        for (Map.Entry<Integer, Integer> entry : this.rankingResults.entrySet()) {
 | 
			
		||||
            stringBuilder.append("Player with ID: ").append(entry.getKey()).append(" rolled: ").append(entry.getValue()).append(", ");
 | 
			
		||||
        }
 | 
			
		||||
        stringBuilder.deleteCharAt(stringBuilder.length() - 1);
 | 
			
		||||
        stringBuilder.deleteCharAt(stringBuilder.length() - 1);
 | 
			
		||||
        stringBuilder.append("}");
 | 
			
		||||
        return stringBuilder.toString();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user