Java Implementation of Toy Robot problem