Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Help needed making a String, which has all the letters in the rack (Scrabble game)

java scrabble game string

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1 BobbyRedSox28


    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 25 May 2015 - 12:58 PM

I have managed to complete the first part asking to create a method, countLetters. It is the second part, make a String, rackString, which has all the letters in the rack, that I am having difficulty with. Can anybody point me in the right direction. I have included my attempt at a solution, but it seems to be incorrect. The code compiles without error, but in the terminal window, every time I input a word it reads, the word you chose doesn't work with your rack.
public static boolean validWord(String word, Tile [] rack)
        // first make a countLetters method below this method
        // that takes a char and a String and returns the number 
        // of times the char value appears in the String. 
        //   See exercise 20 in assessment 8 for a solution to countLetters. 
        // then, make a String, rackString, which has all the letters 
        //   in the rack
        String rackString = new String();
        // then, make a for loop that goes through all the letters in 
        //   String word
        for (int k = 0; k < word.length(); k++)
            if (word.length() > rackString.length())
                return false;
            return true;

#2 WingedPanther73


    A spammer's worst nightmare

  • Moderator
  • 17757 posts

Posted 26 May 2015 - 04:15 AM

Can you clarify what you mean by "has all the letters in the rack"?

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download