This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.junit.Test; | |
import static org.junit.Assert.*; | |
public class MovingObjectTest { | |
@Test | |
public void testDisplacement(){ | |
MovingObject object = new MovingObject(10, 10, 10, 10); | |
assertEquals(600, object.displacement(), 0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Square { | |
public int topLeftCoordinateX; | |
public int topLeftCoordinateY; | |
public int side; | |
} | |
public class AreaCalculator{ | |
public double area(Object shape){ | |
if (shape instanceof Square){ | |
Square square = (Square) shape; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Shape{ | |
double area(); | |
} | |
public class Square { | |
private int topLeftCoordinateX; | |
private int topLeftCoordinateY; | |
private int side; | |
public double area(){ |
OlderNewer