Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li><code>stack</code> appears to have been intended to be an array of the element type, which <code>push(int)</code> tells me is <code>int</code>.</li> <li>What kind of <em>general</em> stack is limited to <code>int</code>?</li> <li><code>setCount</code> appears to have been intended to be <code>maxCapacity</code> in the <code>GeneralStack(int)</code> constructor.</li> <li><p>Your <code>isEmpty()</code> method will not work properly because you have an unintended semicolon after your <code>if</code> condition. <code>if (count == 0) ;</code> means 'if <code>count</code> equals zero, do nothing`. You likely intended:</p> <pre><code>if (count == 0) { isEmpty = true; } </code></pre> <p>In fact, the entire method can be shortened to a single statement.</p></li> <li>The same issue in #3 also applies to <code>isFull()</code>, with a similar shortened form. You also have no <code>maxCapacity</code> variable in scope... perhaps you forgot to declare and initialize a field?</li> <li>Assigning to the stack should be mutating the array element corresponding to the <em>top</em>.</li> <li><code>pop()</code> should not return anything if it is declared <code>void</code>. In addition, <code>count = count - 1</code> can be shortened using the <em>decrement operator</em>, <code>--</code>, e.g. <code>--count;</code>.</li> <li>What presumably you meant to name <code>top()</code> (judging by the code of <code>pop()</code>), you accidentally named <code>topVal()</code>. Additionally, you never declare the <code>topVal</code> variable in the method scope. You can rewrite the method to obviate the need for the variable at all by directly returning the element from the array.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload