// Inheritance Project // shapehierarchy Module // Source code file: Test2.java // Implements this inheritance hierarchy: // Rectangle --> Shape <-- Circle // Instance variables are set with the constructor. import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class Test2 { private final double TOL = 1.0e9; private Shape s; private Rectangle r; private Circle c; @BeforeEach public void testSetUp( ) { s = new Shape(255, 0, 0); r = new Rectangle(0, 255, 0, 2.5, 3.5); c = new Circle(0, 0, 255, 3.0); } @Test public void testGetColor( ) { assertEquals("ff0000", s.getColor( )); assertEquals("00ff00", r.getColor( )); assertEquals("0000ff", c.getColor( )); } @Test public void testToString( ) { assertEquals("Shape -- Color: ff0000", s.toString( )); assertEquals("Rectangle -- Color 00ff00 Width: 2.5000 Height: 3.5000", r.toString( )); assertEquals("Circle -- Color 0000ff Radius: 3.0000", c.toString( )); } @Test public void testGetArea( ) { assertEquals(2.5 * 3.5, r.getArea( ), TOL); assertEquals(Math.PI * 3.0, r.getArea( ), TOL); } }