Reero
Account Details
SteamID64 76561198071785065
SteamID3 [U:1:111519337]
SteamID32 STEAM_0:1:55759668
Country Italy
Signed Up November 15, 2015
Last Posted April 2, 2024 at 9:54 PM
Posts 2103 (0.7 per day)
Game Settings
In-game Sensitivity 6.91
Windows Sensitivity 6/11
Raw Input 1
DPI
400
Resolution
1920x1080
Refresh Rate
240hz
Hardware Peripherals
Mouse Logitech G Pro
Keyboard Logitech G Pro Keyboard
Mousepad Steelseries QCK +
Headphones Apple earbuds
Monitor Alienware 240hz
1 ⋅⋅ 112 113 114 115 116 117 118 ⋅⋅ 137
#39 help me with my coding hw in Off Topic

I don't know C++ but heres a java solution

import java.util.Scanner;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

/**
 * The hangman class includes few methods connected with the hangman game Also includes game method that allows the user
 * to play a round of hangman
 *
 * 
 */
public class Hangman {
    static final Logger LOGGER = LoggerFactory.getLogger(ArrayProccesing.class);
    static Scanner scanner = new Scanner(System.in);

    /**
     * This method returns the capitalized version of the letter as a char. If the character is already a capital
     * letter, no changes are made.
     *
     * @param character
     *            the character that will be capitalized
     * @return capitalized character
     */
    static char capitalize(char character) {
        if (character >= 'a' && character <= 'z') {
            character -= 32;
        }
        return character;
    }

    /**
     * This method returns the capitalized version of a string as every non capital letter in the string is being
     * capitalized.
     *
     * @param str
     *            string that is going to be capitalized
     * @return capitalized string
     */
    static String capitalize(String str) {
        StringBuilder strBuilder = new StringBuilder(str);
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) >= 'a' && str.charAt(i) <= 'z') {
                strBuilder.setCharAt(i, capitalize(str.charAt(i)));
            }
        }
        return strBuilder.toString();
    }

    /**
     * This method reveals a hidden character from a hangman word.
     *
     * @param originalWord
     *            full word e.g."Example"
     * @param unfinishedWord
     *            hidden word e.g."E _ _ _ _ _ E"
     * @param letter
     *            letter that will reveal in the unfinished word
     * @return new unfinished word with revealed letter
     */
    static String hangmanLetterReveal(String originalWord, String unfinishedWord, char letter) {
        StringBuilder stringBuilder = new StringBuilder(unfinishedWord);
        for (int i = 0; i < originalWord.length(); i++) {
            if (originalWord.charAt(i) == letter) {
                stringBuilder.setCharAt(i, letter);
            }
        }
        return stringBuilder.toString();
    }

    /**
     * Makes a string to a hidden string, showing only the first and the last letter
     *
     * @param secredWord
     *            full word e.g."Example"
     * @return encrypted word e.g."E _ _ _ _ _ E"
     */
    static String transferWordForHangman(String secredWord) {
        StringBuilder hangmanWordBuilder = new StringBuilder(secredWord);
        String hangmanWord;

        for (int i = 1; i < secredWord.length() - 1; i++) {
            hangmanWordBuilder.setCharAt(i, '_');
        }

        hangmanWord = hangmanWordBuilder.toString();
        hangmanWord = hangmanLetterReveal(secredWord, hangmanWordBuilder.toString(), secredWord.charAt(0));
        hangmanWord = hangmanLetterReveal(secredWord, hangmanWordBuilder.toString(),
                secredWord.charAt(secredWord.length() - 1));

        return hangmanWord;
    }

    /**
     * Print information about the current state of the game.
     *
     * @param round
     *            the number of the following round
     * @param seenWord
     *            the encrypted word that the player sees
     * @param usedLetters
     *            the letter that the player had already used
     * @param lives
     *            the number of the remaining lives
     */
    public static void printRoundInformation(int round, String seenWord, char[] usedLetters, int lives) {
        LOGGER.info(" ");
        LOGGER.info("Round {}:", round);
        LOGGER.info("Word to guess: {}", seenWord);
        LOGGER.info("Lives: {}", lives);
        LOGGER.info("Used letters: {}", String.valueOf(usedLetters));
    }

    /**
     * Check a given character if it is a letter or not using the ASCII table
     *
     * @param character
     *            that will be tested if it's a letter or not
     * @return true if the character is letter and false if it's not
     */
    public static boolean charIsLetter(char character) {
        return ((character >= 'a' && character <= 'z') || (character >= 'A' && character <= 'Z'));
    }

    /**
     * Checks if given character is in a given string
     *
     * @param character
     *            that will be searched for
     * @param str
     *            the string that may have the character
     * @return true if the character is within the string, false if not.
     */
    public static boolean charIsInString(char character, String str) {
        for (int i = 0; i < str.length(); i++) {
            if (character == str.charAt(i)) {
                return true;
            }
        }
        return false;

    }

    /**
     * Plays a game of Hangman until the player have guessed the word or lost all his lives
     *
     * @param secredWord the word that the player will have to guess
     */
    public static void play(String secredWord) {
        int lives = 5;
        int round = 0;
        char[] usedLetters = new char[26];

        for (int i = 0; i < usedLetters.length; i++) {
            usedLetters[i] = ' ';
        }

        int numUsedLetters = 0;
        String seenWord;
        char chosenLetter;

        secredWord = capitalize(secredWord);
        seenWord = transferWordForHangman(secredWord);

        while (lives > 0 && !secredWord.equals(seenWord)) {
            round++;
            printRoundInformation(round, seenWord, usedLetters, lives);

            chosenLetter = ' ';
            while (!charIsLetter(chosenLetter)) {
                LOGGER.info("Guess a letter: ");
                chosenLetter = scanner.nextLine().charAt(0);
            }
            chosenLetter = capitalize(chosenLetter);
            usedLetters[numUsedLetters++] = chosenLetter;

            if (charIsInString(chosenLetter, secredWord)) {
                LOGGER.info("You guessed right!");
                seenWord = hangmanLetterReveal(secredWord, seenWord, chosenLetter);
            } else {
                LOGGER.info("You guessed wrong! You lose one of your life points.");
                lives--;
            }
        }

        if (lives <= 0) {
            LOGGER.info("You LOST!");
        } else if (secredWord.equals(seenWord)) {
            LOGGER.info("Congratulations! You WON!");
        }

    }

}
posted about 7 years ago
#22 School & TF2 in TF2 General Discussion
rowpieceswhat i did for the longest time was do my hw after i had scrims/ matches which was really dumb. just start getting in the habit of doing your homework when you get home, it helps a lot

this. As soon as you get home from school just bang out your hw/do your studying. If you don't get a topic ask for help in school/ask friends for help. Alternatively you can try to get your hw done after school at the school library or wherever. If you're really fucked on a test or quiz just study as much as you can before scrims then study more afterwards.

posted about 7 years ago
#739 ESEA-O S23 Happenings/Discussion in TF2 General Discussion

gg to fkups it wsa a a fun match

posted about 7 years ago
#4 Custom stickybomb color/model? in Customization

Valve should add colorblind support..

posted about 7 years ago
#65 What are you positive about today? in Off Topic

School is going really well for me :)

posted about 7 years ago
#48 lfp high open in Recruitment (looking for players)

Pls don't let Alanny not win open

posted about 7 years ago
#47 smesi lft in Recruitment (looking for team)

Smesi (Pos 2,966, 988 points) connected (Mexico)

http://pix.iemoji.com/images/emoji/apple/ios-9/256/thinking-face.png

I love Smesi he's such a nice lad :)

posted about 7 years ago
#6 Riot lft open scout in Recruitment (looking for team)

big memer big frag

posted about 7 years ago
#218 Personality Types in Off Topic

https://i.gyazo.com/dad35b0aa2c3b53ef83fb3957aa5c5de.png

posted about 7 years ago
#717 ESEA-O S23 Happenings/Discussion in TF2 General Discussion
ESEA ISSA KNIFE < United Gamers Community 2-4

https://youtu.be/vKhW0JDn9l0

posted about 7 years ago
#708 ESEA-O S23 Happenings/Discussion in TF2 General Discussion

https://play.esea.net/index.php?s=stats&d=match&id=8092445

Rogue_Wulf big 68 frags

posted about 7 years ago
#10 rowpieces lft s24 in Recruitment (looking for team)

bump

posted about 7 years ago
#10 GayPowerJesus lft in Recruitment (looking for team)

PogChamp

nutty demo

posted about 7 years ago
#10 How's your team faired so far this season? in TF2 General Discussion

My 1st season of esea has taught me so much about this game :)

posted about 7 years ago
#70 mc lft in Recruitment (looking for team)

He's a god

posted about 7 years ago
1 ⋅⋅ 112 113 114 115 116 117 118 ⋅⋅ 137