All homeworks are due before class on the due date. All homework assignments must reflect your own understanding of the topic and be communicated in your own words. You may use one of the collaborative options. You may also request help and advice from your classmates on Piazza. Any help not allowed by that policy will be an honor violation.
Purpose: To encourage students to start working on the homework assignments early and recognize students who are actively engaged in the content
You will receiveNote: The final submission timestamp shown on Gradescope will be used.
Consider BoundedQueue.java.
Although we do not expect you to satisfy any specific test criterion, at minimum, your tests must reach every line of code in the method.
Reminder: do not modify the program under test
Consider Cal.java.
Apply RIPR model to design tests, develop JUnit data-driven tests for the cal() method. — the cal() method only. Do not develop tests for the main() and getN() methods. Since there is a precondition excluding basically all invalid inputs, you should test normal behavior only.
Although we do not expect you to satisfy any specific test criterion, at minimum, your tests must reach every line of code in the method.
Reminder: do not modify the program under test
Consider the following Java class. PrimeNumbers has three methods.
public class PrimeNumbers implements Iterable<Integer>
{
private List<Integer> primes = new ArrayList<Integer>();
public void computePrimes(int n)
{
int count = 1; // count of primes
int number = 2; // number tested for primeness
boolean isPrime; // is this number a prime
while (count <= n)
{
isPrime = true;
for (int divisor = 2; divisor <= number / 2; divisor++)
{
if (number % divisor == 0)
{
isPrime = false;
break; // for loop
}
}
if (isPrime && (number % 10 != 9)) // FAULT
{
primes.add(number);
count++;
}
number++;
}
}
@Override public Iterator<Integer> iterator()
{
return primes.iterator();
}
@Override public String toString()
{
return primes.toString();
}
}
computePrimes() has a fault that causes it not to include prime numbers whose last digit is 9 (for example, it omits 19, 29, 59, 79, 89, 109, ...).
If possible, describe the following five tests. You can describe the tests as sequences of calls to the above methods, or briefly describe them in words. Be sure to include test input values and expected outputs. Note that the last two tests require the test oracle to be described.
If a test cannot be created, explain why.
( -5 points) for 24 hours late (submitted after 22-September 11am EST, by 23-September 11am EST)
(-10 points) for 48 hours late (submitted after 23-September 11am EST, by 24-September 11am EST)
(-2 points) for submitting a Word document or handwriting, or a write-up that is not a typed PDF file.
Log in to Canvas, then upload your report as a PDF to Assignment2 on Gradescope. Make sure you connect your partner to your group on Gradescope so that everyone receives credit.
Each team submits only one copy.
Making your submission available to instructor and course staff is your responsibility; if we cannot access or open your file, you will not get credit. Be sure to test access to your file before the due date.
CC-BY-NC-SA 4.0 license.