package test2; /** * A class that represents rotations in the 2D plane. A rotation * is defined by an angle of rotation and the units used to * represent the rotation. * */ public class Rotation { /** * String for units in degrees. */ public static final String DEGREES = "degrees"; /** * String for units in radians. */ public static final String RADIANS = "radians"; /** * The angle of the rotation. */ private double angle; /** * The units of the angle. */ private String units; /** * Initializes the rotation to 0 radians. */ public Rotation() { this(0.0, Rotation.RADIANS); } /** * Initializes the rotation to the given angle using the given * units. * * @param angle the angle of the rotation * @param units the units of the angle * @throws IllegalArgumentException if units is not equal * to Rotation.DEGREES or Rotation.RADIANS */ public Rotation(double angle, String units) { if (units.equals(Rotation.DEGREES) || units.equals(Rotation.RADIANS)) { this.angle = angle; this.units = units; } else { throw new IllegalArgumentException(); } } }