Problem Statement
A point on a circle can be specified by giving an angle measured in degrees counterclockwise
from the positive x-axis. 90, 450, -270 all are angles that specify the point at the
top of the circle. We are going to travel counterclockwise along the circle
between a start and finish point, stopping as soon as we reach the finish point. (We will always
travel less than one revolution.) We have a list of named points on the circle and
we want to know which ones we will visit.
The first point in the list is named 'A', the next point in the list is named 'B', etc.
Create a class Circles that contains the method visit that takes as input the starting point specified by an int start, the finish point specified by an int finish, and the list of named points specified by a int[] points and returns a String consisting of the names of the visited points in the order of visitation. The returned String should contain no spaces.
Definition
- Class:
- Circles
- Method:
- visit
- Parameters:
- int, int, int[]
- Returns:
- String
- Method signature:
- String visit(int start, int finish, int[] points)
- (be sure your method is public)
Notes
- Adding (or subtracting) 360 to any degree quantity produces an equivalent degree quantity.
Constraints
- start is between -1000 and 1000 inclusive
- finish is between -1000 and 1000 inclusive
- points contains between 0 and 26 elements, inclusive
- each element of points is between -1000 and 1000 inclusive
- start, finish, and each element of points all specify distinct points
Examples
5
50
{-315,-20,12}Returns: "CA"
The point C (12 degrees) is visited first, then A (-315 == 45). B is never visited as we move counterclockwise from 5 to 50.320
-320
{50,180,75,300}Returns: ""
We visit none of the named points as we travel counterclockwise from 320 to -320.2
-355
{363,4,6}Returns: "AB"
350
10
{0,9,-1,351}Returns: "DCAB"