Question: I have included each of the .java classes below the instructions public class CptS132Circle extends CptS132Shape { public CptS132Circle(int d) { super(d, d); } public
I have included each of the .java classes below the instructions
public class CptS132Circle extends CptS132Shape {
public CptS132Circle(int d) {
super(d, d);
}
public int getDiameter() {
return getWidth();
}
public double getArea() {
return Math.PI * getDiameter() * getDiameter() / 4;
}
}
public abstract class CptS132Shape {
private int width;
private int height;
public CptS132Shape(int w, int h) {
if(w
throw new IllegalArgumentException("Dimensions cannot be negative");
if(w>1000 || h>1000)
throw new IllegalArgumentException("Dimensions cannot be greater than 1,000");
width = w;
height = h;
}
protected int getWidth() {
return width;
}
protected int getHeight() {
return height;
}
public abstract double getArea();
}
public class CtpS132Triangle extends CptS132Shape {
public CtpS132Triangle(int b, int h) {
super(b, h);
}
public int getBase() {
return getWidth();
}
public int getHeight() {
return super.getHeight();
}
public double getArea() {
return getBase() * getHeight() / 2;
}
}
public class CtpS132Rectangle extends CptS132Shape {
public CtpS132Rectangle(int h, int w) {
super(h, w);
}
public int getHeight() {
return super.getHeight();
}
public int getWidth() {
return super.getWidth();
}
public double getArea() {
return getHeight() * getWidth();
}
}
Instructions JUnit is a commonly-used library for unit testing in Java. For this lab, you will create unit tests for a very simple class hierarchy Important Note: There are some errors in the provided hierarchy. The goal of this activity is not correcting those errors. Instead, the goal is the creation of test cases, and therefore identifying the errors. Starting point code Download the starting point zip, which includes the following files CptS132Shape.java CptS132Circle.java CptS132Triangle.java CptS132Rectangle.java Create three separate classes, one to test each of the concrete classes: CptS132Rectangle, CptS132Triangle, CptS132Circle. The test cases should be created using JUnit4 JUnit 4 No inheritance requirement, instead annotations . Individual test cases: @org.junit.Test public void xxxx ) modifier: public return type: void no parameters: ) . Assert methods are static within org.junit.Assert Typically, imports: import org.junit.*; import static org.junit.Assert.*; Test environment annotations: @Before public void xxxx () CAfter public void Xxx () Submission Source code for the JUnit tests TestCptS132Circle.java * TestCptS132Rectangle.java * TestCptS132Triangle.java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
