/** * ReformatProb - sample Java code to demonstrate AStyle
* Author: J. Dalbey
Date: May 2, 2001 Doesn't reformat text within comments */ public class ReformatProb { private int RowHideSpot; private int ColHideSpot; /** * Constructor * Assign random positions for Row and Column hiding spots
* RowHideSpot is assigned a random character between 'a' and 'i'
* ColHideSpot is assigned a random integer between 1 and 9 */ public ReformatProb() { RowHideSpot = (char) ((105 - 97 + 1) * Math.random() + 97); ColHideSpot = (int) ((9 - 1 + 1) * Math.random() + 1); } public String getClue(char RowGuess, int ColGuess ) { String Clue = ""; if (!isFound( RowGuess, ColGuess)) { Clue = "Go "; if (RowGuess > RowHideSpot) Clue = Clue + "North"; else if (RowGuess < RowHideSpot) Clue = Clue + "South"; if (ColGuess > ColHideSpot) Clue = Clue + "West"; else if (ColGuess < ColHideSpot) { Clue = Clue + "East"; } } return Clue; } /** * isFound determines if the guess matches the hiding spot * @return true if the row and column guesses equal the hurkle hiding place, * false otherwise */ public boolean isFound( char RowGuess, int ColGuess ) { int a = 0; switch (ColGuess) { case 1: { a += 2; break; } default: { a += 2; break; } } return ((RowHideSpot == RowGuess) && (ColHideSpot == ColGuess)); } /** * revealSpot - reveals the Hurkle's location * @return a message describing the hiding spot */ public String revealSpot() { return ("Row:" + RowHideSpot + " Column: " + ColHideSpot); } } // end class