I have two classes. The application Starter is Called StartBattleShip. My Second Class is BattleShip. When I try to complie StartBattleShip I get two errors. The They both say they cannot find symbol , symbol : class BattleShip.
I have tried just about everything I could think of. I have typed in the command prompt set classpath = . That didn't even help. Here is the Code.
Code:public class StartBattleShip { public static void main(String[] Args) { BattleShip play = new BattleShip(); int[] locations = {2,3,4}; play.setLocationCells(locations); String userGuess = "2"; String result = play.checkGuess(userGuess); } }Any help would be appreciated. I am just too frustrated. I am sure it is something very simple. This is just the begining. I plan to expand it but for now I am trying to just get the basic to work.Code:class BattleShip { int[] locationCells; int numberOfHits = 0; public void setLocationCells(int[] locs) { locationCells = locs; } public String checkGuess(String stringGuess) { int guess = Integer.parseInt(stringGuess); String result = "miss"; for(int cells : locationCells) { if(guess == cells) { result = "hit"; numberOfHits++; break; } } if(numberOfHits == locationCells.length) { result = "Kill" ; } System.out.println(result); return result; } }


Reply With Quote


Bookmarks