Question: IntStackTestBase.java ------------------- import org.junit.jupiter.api.Test; public abstract class IntStackTestBase { protected abstract T newInstance(); @Test void testNewInstance() { IntStack stack = newInstance(); } } ---------------- IntStack0.class

 IntStackTestBase.java ------------------- import org.junit.jupiter.api.Test; public abstract class IntStackTestBase { protected abstract

IntStackTestBase.java

-------------------

import org.junit.jupiter.api.Test; public abstract class IntStackTestBase { protected abstract T newInstance(); @Test void testNewInstance() { IntStack stack = newInstance(); } } 

----------------

IntStack0.class

----------------

public class IntStack0 implements IntStack { int size = 0; int[] values = new int[10]; public IntStack0() { } public void push(int i) { if (this.size = 0) { System.arraycopy(oldValues, 0, this.values, 0, oldValues.length); } this.push(i); } } public int pop() { if (this.size > 0) { int ret = this.values[this.size]; --this.size; return ret; } else { throw new ArrayIndexOutOfBoundsException(); } } public int size() { return this.size; } public boolean isEmpty() { return this.size == 0; } } 

----------------

IntStack1.class

----------------

public class IntStack1 implements IntStack { int size = 0; int[] values = new int[10]; public IntStack1() { } public void push(int i) { if (this.size  0) { int ret = this.values[this.size]; --this.size; return ret; } else { throw new ArrayIndexOutOfBoundsException(); } } public int size() { return this.size; } public boolean isEmpty() { return this.size == 0; } } 

------------------

IntStack2.class

------------------

public class IntStack2 implements IntStack { int size = 0; int[] values = new int[5]; public IntStack2() { } public void push(int i) { if (this.size = 0) { System.arraycopy(oldValues, 0, this.values, 0, oldValues.length); } this.push(i); } } public int pop() { if (this.size > 0) { --this.size; int ret = this.values[this.size]; return ret; } else { throw new ArrayIndexOutOfBoundsException(); } } public int size() { return this.size; } public boolean isEmpty() { return this.size == 0; } } 

The IntStack classes are provided in .class form only, meaning you do not have access to their source code. Two of them contain bugs and one is correct. Your assignment is write tests for the IntStack classes and determine which of the classes are bugged and which is correct. To make that determination, it should be sufficient to write tests that properly exercise all of the properties of the operations of the stack. That is to say, the bugs are not supposed to be tricky or difficult to find. New tests should be added to the IntStackTestBase class so that they can be inherited by the IntStackotest, IntStackitest, and IntStack2test classes, which actually test each of the corresponding IntStack classes. In your tests, you should use the newInstance method rather than use the new operator. This is to ensure that you get an instance of which ever IntStack class you're currently testing Extra credit: 1 point of extra credit for each bugged class is available (ie 2 points total) if you can accurately describe what the source or cause of the bug is. You should turn in your modified IntStackTestBase.java file and a document containing your answers regarding which classes contain a bug and, if attempted, the extra credit question. Turn in your modified IntStackTestBase.java file along with a document with the answers about which classes contained a bug. If you worked on and completed the extra credit question, include your answers too (if you attempted it). The IntStack classes are provided in .class form only, meaning you do not have access to their source code. Two of them contain bugs and one is correct. Your assignment is write tests for the IntStack classes and determine which of the classes are bugged and which is correct. To make that determination, it should be sufficient to write tests that properly exercise all of the properties of the operations of the stack. That is to say, the bugs are not supposed to be tricky or difficult to find. New tests should be added to the IntStackTestBase class so that they can be inherited by the IntStackotest, IntStackitest, and IntStack2test classes, which actually test each of the corresponding IntStack classes. In your tests, you should use the newInstance method rather than use the new operator. This is to ensure that you get an instance of which ever IntStack class you're currently testing Extra credit: 1 point of extra credit for each bugged class is available (ie 2 points total) if you can accurately describe what the source or cause of the bug is. You should turn in your modified IntStackTestBase.java file and a document containing your answers regarding which classes contain a bug and, if attempted, the extra credit question. Turn in your modified IntStackTestBase.java file along with a document with the answers about which classes contained a bug. If you worked on and completed the extra credit question, include your answers too (if you attempted it)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!