Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws Exception {
- if(args.length==0) {
- throw new Exception("no arg given brother man");
- }
- File file_voc=new File(args[0]);
- Scanner scanner=new Scanner(file_voc);
- String[] my_words=WordPuzzle.scanVocabulary(scanner);
- printReadVocabulary(args[0], my_words.length);
- //System.out.println("Read "+my_words.length+" words from "+args[0]);
- printSettingsMessage();
- //System.out.println("--- Setting stage ---");
- Scanner online_scan=new Scanner(System.in);
- Random generator = new MyRandom(new int[]{0,1,2,3,4,5},new float[]{0.0f,0.1f,0.2f,0.3f,0.4f,0.5f,0.6f,0.7f,0.8f,0.9f,1.0f});
- printEnterHidingProbability();
- //System.out.println("Enter your hiding probability:");
- String userProbStr = online_scan.nextLine();
- float userProbFloat = Float.parseFloat(userProbStr);
- boolean flagish = false;
- String no = "no";
- String yes = "yes";
- String randWord = null;
- char[] thePuzzleCreated = null;
- while (flagish != true) {
- randWord = getRandomWord(my_words, generator);
- thePuzzleCreated = getRandomPuzzle(randWord, userProbFloat, generator);
- printPuzzle(thePuzzleCreated);
- printReplacePuzzleMessage();
- String ans = online_scan.next();
- while (!!!ans.equals(yes) && !!!ans.equals(no)) {
- printReplacePuzzleMessage();
- ans = online_scan.next();
- }
- if (!!ans.equals(no)) {
- flagish = true;
- }
- }
- printGameStageMessage();
- System.out.println(thePuzzleCreated);
- //System.out.println("--- Game stage ---");
- int numOfHidden = countHowMany(thePuzzleCreated,HIDDEN_CHAR);
- int attempts = numOfHidden +3 ;
- /*for(char ch:her_puzzle) {
- if (ch=='_') {
- counter_hidden++;
- }
- }*/
- /*
- * for(char ch: her_puzzle) System.out.print(ch);
- */
- while (attempts>0) {
- printEnterYourGuessMessage();
- String guess =online_scan.next();
- if(WordPuzzle.applyGuess(guess.charAt(0),randWord, thePuzzleCreated)>=1) {
- /*
- * int counting_hidden=0; for(char ch:her_puzzle) { if (ch=='_') {
- * counting_hidden++; } }
- */
- int numOfHiddenNew = countHowMany(thePuzzleCreated,HIDDEN_CHAR);
- if(numOfHiddenNew==0) {
- printWinMessage();
- break;
- }
- else {
- int a = attempts - 1 ;
- printCorrectGuess(a);
- //System.out.println("Correct Guess, "+(attempts-1)+" guesses left");
- System.out.println(thePuzzleCreated);
- }
- }
- else if(guess.equals("H")){
- getHelp(randWord, thePuzzleCreated);
- int tempNumhidden = countHowMany(thePuzzleCreated, HIDDEN_CHAR);
- if(tempNumhidden==0) {
- printWinMessage();
- break;
- }
- System.out.println(thePuzzleCreated);
- attempts--;
- }
- else {
- int attemptsNum = attempts -1;
- printWrongGuess(attemptsNum);
- //System.out.println("Wrong Guess, "+(attempts-1)+" guesses left");
- }
- attempts--;
- }
- if(attempts==0) {
- printGameOver();
- }
- scanner.close();
- online_scan.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement