318 lines
9.7 KiB
HTML
318 lines
9.7 KiB
HTML
|
|
|
|
|
|
<!DOCTYPE html>
|
|
<html id="htmlId">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
|
<title>Coverage Report > Slot</title>
|
|
<style type="text/css">
|
|
@import "../../css/coverage.css";
|
|
@import "../../css/idea.min.css";
|
|
</style>
|
|
<script type="text/javascript" src="../../js/highlight.min.js"></script>
|
|
<script type="text/javascript" src="../../js/highlightjs-line-numbers.min.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="content">
|
|
<div class="breadCrumbs">
|
|
Current scope: <a href="../../index.html">all classes</a>
|
|
<span class="separator">|</span>
|
|
<a href="../index.html">it.polimi.ingsw.gc14.Model</a>
|
|
</div>
|
|
|
|
<h1>Coverage Summary for Class: Slot (it.polimi.ingsw.gc14.Model)</h1>
|
|
|
|
<table class="coverageStats">
|
|
<tr>
|
|
<th class="name">Class</th>
|
|
<th class="coverageStat
|
|
">
|
|
Class, %
|
|
</th>
|
|
<th class="coverageStat
|
|
">
|
|
Method, %
|
|
</th>
|
|
<th class="coverageStat
|
|
">
|
|
Branch, %
|
|
</th>
|
|
<th class="coverageStat
|
|
">
|
|
Line, %
|
|
</th>
|
|
</tr>
|
|
<tr>
|
|
<td class="name">Slot</td>
|
|
<td class="coverageStat">
|
|
<span class="percent">
|
|
100%
|
|
</span>
|
|
<span class="absValue">
|
|
(1/1)
|
|
</span>
|
|
</td>
|
|
<td class="coverageStat">
|
|
<span class="percent">
|
|
90%
|
|
</span>
|
|
<span class="absValue">
|
|
(9/10)
|
|
</span>
|
|
</td>
|
|
<td class="coverageStat">
|
|
<span class="percent">
|
|
53.3%
|
|
</span>
|
|
<span class="absValue">
|
|
(8/15)
|
|
</span>
|
|
</td>
|
|
<td class="coverageStat">
|
|
<span class="percent">
|
|
82.2%
|
|
</span>
|
|
<span class="absValue">
|
|
(37/45)
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<br/>
|
|
<br/>
|
|
|
|
|
|
<pre>
|
|
<code class="sourceCode" id="sourceCode"> package it.polimi.ingsw.gc14.Model;
|
|
import java.io.Serializable;
|
|
|
|
/**
|
|
* Represents a slot with a specific identifier and associated values
|
|
* for upper cards, lower cards, food, and minimum number of players.
|
|
* The slot configuration depends on the specified slot identifier.
|
|
*/
|
|
public class Slot implements Serializable {
|
|
|
|
/**
|
|
* The identifier of this slot.
|
|
*/
|
|
private final char slotId;
|
|
|
|
/**
|
|
* Returns the identifier of this slot.
|
|
*
|
|
* @return the identifier of this slot.
|
|
*/
|
|
public char getSlotId() {
|
|
<b class="fc"> return slotId;</b>
|
|
}
|
|
|
|
/**
|
|
* The number of upper cards associated with this slot.
|
|
*/
|
|
private final int nUpper;
|
|
/**
|
|
* Returns the number of upper cards associated with this slot.
|
|
*
|
|
* @return the number of upper cards associated with this slot.
|
|
*/
|
|
public int getNUpper(){
|
|
<b class="fc"> return nUpper;</b>
|
|
}
|
|
|
|
/**
|
|
* The minimum number of players required for this slot.
|
|
*/
|
|
private int nMinPlayer;
|
|
|
|
/**
|
|
* Returns the minimum number of players required for this slot.
|
|
*
|
|
* @return the minimum number of players required for this slot.
|
|
*/
|
|
public int getNMinPlayer()
|
|
{
|
|
<b class="fc"> return nMinPlayer;</b>
|
|
}
|
|
|
|
/**
|
|
* The number of lower cards associated with this slot.
|
|
*/
|
|
private final int nLower;
|
|
|
|
/**
|
|
* Returns the number of lower cards associated with this slot.
|
|
*
|
|
* @return the number of lower cards associated with this slot.
|
|
*/
|
|
public int getNLower(){
|
|
<b class="fc"> return nLower;</b>
|
|
}
|
|
|
|
/**
|
|
* The amount of Food associated with this slot.
|
|
*/
|
|
private final int food;
|
|
|
|
/**
|
|
* Returns the amount of Food associated with this slot.
|
|
*
|
|
* @return the amount of Food associated with this slot.
|
|
*/
|
|
public int getFood(){
|
|
<b class="fc"> return food;</b>
|
|
}
|
|
|
|
|
|
/**
|
|
* Creates a slot with the specified identifier.
|
|
* The slot values for Food, NLower, NUpper, and minimum number of players
|
|
* are determined by the given slot identifier.
|
|
*
|
|
* @param slotId the identifier of the slot.
|
|
* @throws IllegalArgumentException if the specified slot identifier is not valid.
|
|
*/
|
|
public Slot(char slotId) throws IllegalArgumentException
|
|
<b class="fc"> {</b>
|
|
<b class="fc"> this.slotId = slotId;</b>
|
|
<b class="fc"> this.nMinPlayer=0;</b>
|
|
<b class="fc"> switch(slotId)</b>
|
|
{
|
|
case 'A':
|
|
<b class="fc"> this.food = 3;</b>
|
|
<b class="fc"> this.nLower = 0;</b>
|
|
<b class="fc"> this.nUpper = 0;</b>
|
|
<b class="fc"> this.nMinPlayer=5;</b>
|
|
break;
|
|
case 'B':
|
|
<b class="fc"> this.food = 0;</b>
|
|
<b class="fc"> this.nLower = 1;</b>
|
|
<b class="fc"> this.nUpper = 0;</b>
|
|
break;
|
|
case 'C':
|
|
<b class="fc"> this.food = 0;</b>
|
|
<b class="fc"> this.nLower = 0;</b>
|
|
<b class="fc"> this.nUpper = 1;</b>
|
|
break;
|
|
case 'D':
|
|
<b class="fc"> this.food = 0;</b>
|
|
<b class="fc"> this.nLower = 2;</b>
|
|
<b class="fc"> this.nUpper = 0;</b>
|
|
<b class="fc"> this.nMinPlayer = 3;</b>
|
|
break;
|
|
case 'E':
|
|
<b class="fc"> this.food = 0;</b>
|
|
<b class="fc"> this.nLower = 1;</b>
|
|
<b class="fc"> this.nUpper = 1;</b>
|
|
break;
|
|
case 'F':
|
|
<b class="fc"> this.food = 0;</b>
|
|
<b class="fc"> this.nLower = 0;</b>
|
|
<b class="fc"> this.nUpper = 2;</b>
|
|
break;
|
|
case 'G':
|
|
<b class="fc"> this.food = 0;</b>
|
|
<b class="fc"> this.nLower = 1;</b>
|
|
<b class="fc"> this.nUpper = 2;</b>
|
|
<b class="fc"> this.nMinPlayer = 4;</b>
|
|
break;
|
|
default:
|
|
<b class="fc"> throw new IllegalArgumentException();</b>
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns the string representation of this slot.
|
|
* The returned string includes the slot identifier, number of upper cards,
|
|
* number of lower cards, food value, and minimum number of players.
|
|
*
|
|
* @return the string representation of this slot.
|
|
*/
|
|
@Override
|
|
public String toString() {
|
|
<b class="fc"> return ("SlotID: "+this.getSlotId()+"\nNUpper: "+this.getNUpper()+"\nNLower: "+this.getNLower()+"\nFood: "+this.getFood()+"\n");</b>
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns a compact string representation of this {@code Slot} for the TUI.
|
|
* <p>Includes:
|
|
* <ul>
|
|
* <li>{@link #slotId}</li>
|
|
* <li>{@link #nUpper} (shown as ▲ symbols)</li>
|
|
* <li>{@link #nLower} (shown as ▼ symbols)</li>
|
|
* <li>{@link #food} (if non-zero)</li>
|
|
* </ul>
|
|
* @return a compact TUI string representation of this {@code Slot}.
|
|
* @see it.polimi.ingsw.gc14.Model.Game Game
|
|
* @see it.polimi.ingsw.gc14.Model.GamePackage.Board Board
|
|
*/
|
|
public String toStringTUI()
|
|
{
|
|
<b class="nc"> StringBuilder s = new StringBuilder(" ");</b>
|
|
<b class="nc"> s.repeat("▲", Math.max(0, this.getNUpper()));</b>
|
|
<b class="nc"> s.repeat("▼", Math.max(0, this.getNLower()));</b>
|
|
<b class="nc"> if(getFood()!=0) s.append("+").append(getFood()).append(" \uD83C\uDF56");</b>
|
|
<b class="nc"> s.append(" ");</b>
|
|
<b class="nc"> return s.toString();</b>
|
|
}
|
|
|
|
|
|
/**
|
|
* Checks equality between this {@code Slot} and another object.
|
|
* Two slots are equal if and only if they share the same {@code slotId}.
|
|
*
|
|
* @param obj the object to compare with.
|
|
* @return {@code true} if {@code obj} is a {@code Slot} with the same identifier; {@code false} otherwise.
|
|
*/
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
<b class="pc"> if (this == obj) return true;</b>
|
|
<b class="nc"> if (!(obj instanceof Slot)) return false;</b>
|
|
<b class="nc"> return slotId == ((Slot) obj).slotId;</b>
|
|
}
|
|
|
|
/**
|
|
* Returns the hash code for this {@code Slot}, derived from {@link #slotId}.
|
|
*
|
|
* @return the hash code of the slot identifier.
|
|
*/
|
|
@Override
|
|
public int hashCode() {
|
|
<b class="fc"> return Character.hashCode(slotId);</b>
|
|
}
|
|
|
|
}
|
|
</code>
|
|
</pre>
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
|
(function() {
|
|
var msie = false, msie9 = false;
|
|
/*@cc_on
|
|
msie = true;
|
|
@if (@_jscript_version >= 9)
|
|
msie9 = true;
|
|
@end
|
|
@*/
|
|
|
|
if (!msie || msie && msie9) {
|
|
hljs.highlightAll()
|
|
hljs.initLineNumbersOnLoad();
|
|
}
|
|
})();
|
|
</script>
|
|
|
|
<div class="footer">
|
|
|
|
<div style="float:right;">generated on 2026-06-19 22:53</div>
|
|
</div>
|
|
</body>
|
|
</html>
|