Files
Progetto-ingegneria-del-sof…/deliverables/Coverage/htmlReport/ns-b/sources/source-4.html
T
2026-06-19 21:50:38 +02:00

221 lines
6.7 KiB
HTML

<!DOCTYPE html>
<html id="htmlId">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Coverage Report > Order5</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.Orders</a>
</div>
<h1>Coverage Summary for Class: Order5 (it.polimi.ingsw.gc14.Model.Orders)</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">Order5</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(1/1)
</span>
</td>
<td class="coverageStat">
<span class="percent">
100%
</span>
<span class="absValue">
(3/3)
</span>
</td>
<td class="coverageStat">
<span class="percent">
90%
</span>
<span class="absValue">
(18/20)
</span>
</td>
<td class="coverageStat">
<span class="percent">
96.7%
</span>
<span class="absValue">
(29/30)
</span>
</td>
</tr>
</table>
<br/>
<br/>
<pre>
<code class="sourceCode" id="sourceCode">&nbsp;package it.polimi.ingsw.gc14.Model.Orders;
&nbsp;
&nbsp;import it.polimi.ingsw.gc14.Model.OrderLogicCard;
&nbsp;import it.polimi.ingsw.gc14.Model.Player;
&nbsp;import it.polimi.ingsw.gc14.View.TUI.AsciiTable;
&nbsp;import it.polimi.ingsw.gc14.View.TUI.BorderStyle;
&nbsp;
&nbsp;import java.util.ArrayList;
&nbsp;import java.util.List;
&nbsp;import java.util.NoSuchElementException;
&nbsp;
&nbsp;/**
&nbsp; * Represents the order logic card used in a five-player game.
&nbsp; *
&nbsp; * &lt;p&gt;This class defines the specific turn-order behavior for games with
&nbsp; * five players.
&nbsp; */
&nbsp;public class Order5 extends OrderLogicCard {
&nbsp;
&nbsp; /**
&nbsp; * Creates an Order5 logic card for a five-player game.
&nbsp; *
&nbsp; * @param players the list of players associated with this order card.
&nbsp; * @throws NoSuchElementException if the number of players is not equal to 5.
&nbsp; */
&nbsp; public Order5(ArrayList&lt;Player&gt; players) throws NoSuchElementException{
<b class="fc">&nbsp; super(players);</b>
<b class="fc">&nbsp; if(players.size()!=5)</b>
<b class="fc">&nbsp; throw new NoSuchElementException();</b>
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Applies the effect associated with the specified position index for the given player.
&nbsp; * &lt;p&gt;If {@code index == 0}, the player gains 3 Food and the building effect is applied.
&nbsp; * &lt;p&gt;If {@code index == 1}, the player gains 1 Food and the building effect is applied.
&nbsp; * &lt;p&gt;If {@code index == 2}, no effect is applied.
&nbsp; * &lt;p&gt;If {@code index == 3}, no effect is applied.
&nbsp; * &lt;p&gt;If {@code index == 4}, the player tries to remove 1 Food; if the player cannot pay it,
&nbsp; * the player loses 2 Prestige.
&nbsp; *
&nbsp; * @param player the player to whom the effect is applied.
&nbsp; * @param index the position index of the effect to apply.
&nbsp; * @throws IndexOutOfBoundsException if {@code index &lt; 0} or {@code index &gt;= 5}.
&nbsp; */
&nbsp; @Override
&nbsp; protected void effect(Player player,int index) throws IndexOutOfBoundsException
&nbsp; {
<b class="pc">&nbsp; if(index&gt;=5 || index &lt; 0)</b>
&nbsp; {
<b class="fc">&nbsp; throw new IndexOutOfBoundsException(&quot;index out of bounds&quot;);</b>
&nbsp; }
<b class="fc">&nbsp; if(index==0)</b>
&nbsp; {
<b class="fc">&nbsp; player.addFood(3);</b>
<b class="fc">&nbsp; buildingEffect(player);</b>
&nbsp; return;
&nbsp; }
<b class="fc">&nbsp; if(index==1)</b>
&nbsp; {
<b class="fc">&nbsp; player.addFood(1);</b>
<b class="fc">&nbsp; buildingEffect(player);</b>
&nbsp; return;
&nbsp; }
<b class="fc">&nbsp; if(index==4){</b>
<b class="fc">&nbsp; if(!player.removeFood(1)){</b>
<b class="fc">&nbsp; player.removePrestige(2);</b>
&nbsp; }
&nbsp; }
&nbsp; }
&nbsp;
&nbsp; /**
&nbsp; * Creates the TURN ORDER box of the TUI.
&nbsp; * @return the string containing the box
&nbsp; */
&nbsp; @Override
&nbsp; public String toString()
&nbsp; {
&nbsp;
<b class="fc">&nbsp; var table = new AsciiTable(BorderStyle.ROUNDED, 5);</b>
<b class="fc">&nbsp; List&lt;String&gt; stringUp=new ArrayList&lt;&gt;();</b>
<b class="fc">&nbsp; for(int i=0;i&lt;5;i++)</b>
&nbsp; {
&nbsp; try {
<b class="fc">&nbsp; if(playerList.get(i).isPlayed())</b>
<b class="fc">&nbsp; stringUp.add(&quot;&quot;);</b>
&nbsp; else
<b class="pc">&nbsp; stringUp.add(i + &quot;. &quot; + (playerList.get(i).getPlayer().getTotem() != null ? playerList.get(i).getPlayer().getTotem().toString() : playerList.get(i).getPlayer().getUserName()));</b>
&nbsp; }
&nbsp; catch (IndexOutOfBoundsException e) {
<b class="nc">&nbsp; stringUp.add(&quot;&quot;);</b>
&nbsp; }
&nbsp; }
<b class="fc">&nbsp; table.addRow(stringUp);</b>
&nbsp;
<b class="fc">&nbsp; List&lt;String&gt; stringList=new ArrayList&lt;&gt;();</b>
<b class="fc">&nbsp; stringList.add(&quot;+3\uD83C\uDF56&quot;);</b>
<b class="fc">&nbsp; stringList.add(&quot;+1\uD83C\uDF56&quot;);</b>
<b class="fc">&nbsp; stringList.add(&quot;--&quot;);</b>
<b class="fc">&nbsp; stringList.add(&quot;--&quot;);</b>
<b class="fc">&nbsp; stringList.add(&quot;-1\uD83C\uDF56/-2\uD83C\uDFC5&quot;);</b>
<b class="fc">&nbsp; table.addRow(stringList);</b>
<b class="fc">&nbsp; return table.build() + &quot;\n&quot;;</b>
&nbsp; }
&nbsp;}
</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-14 21:53</div>
</div>
</body>
</html>