

-----------------------------------

scottyrush13

Thu Nov 29, 2007 8:34 am


Scrabble Program Help

-----------------------------------

For this java exercise we were given 2 .java files, one called ScrabbleTools.java, and one called ScrabbleScoring.java.  We aren't allowed to alter ScrabbleScoring.java.
Now the ScrabbleScoring program calls on another program to work, the ScrabbleTools, which is two methods that WE need to create.
The two methods together need to calculate the amount of points any given word is worth, words with numbers or spaces return a score of INVALID WORD.
Now one of the methods is getWordScore, and the other is getLetterScore

The getLetterScore method is called by the getWordScore method, those are the two methods we have to write.
The teacher said our program will be tested with his driver program that we don't get to see or use, but I will upload the two files we have.
*NOTE* the ScrabbleScoring.java file cannot be altered in ANY WAY

I'm not asking for anyone to DO the program or anything like that, I just am not very good with these methods and would like someone to give me a little bit of a push for hwo to go about creating these methods, and give me something I can work with.  Just help me get this ball rolling.

Any input at all is GREATLY appreciated.


-----------------------------------

scottyrush13

Thu Nov 29, 2007 9:45 am


Re: Scrabble Program Help

-----------------------------------

Okay so I figured I would screw around a bit, and I have no clue if Im on the right track with this, but for ScrabbleTools.java, I created a switch for each of the different scoring possibilities in the getLetterScore method

 switch (letter)
		 {
		 case 1: letter= 'A'| 'E'|'I'|'L'|'N'|'O'|'R'|'S'|'T'|'U';
		 letterScore=1;
		 return letterScore;
		 break;
		 
		 case 2: letter= 'D'|'G';
		 letterScore=2;
		 return letterScore;
		 break;
		 
		 case 3: letter= 'B'|'C'|'M'|'P';
		 letterScore=3;
		 return letterScore;
		 break;
etc...

I was wondering if it would work if I put a for loop in the getWordScore method that as it went through the array of char's for the users inputted word, it would add the score up everytime in the loop calling this method to see how much the letter is worth?


-----------------------------------

HeavenAgain

Thu Nov 29, 2007 11:01 am


RE:Scrabble Program Help

-----------------------------------

well, this isnt too hard is it? when user enters the word, you first break it down to characters, and you must sort the letter points yourself, example
pointOne = "ABCDEF";
pointTwo= "GHIJK"
in upper case to match your inputs. and now just find each letter in the word (if its not found in any of those, then it must be illegal, number or space), if they match any index of the points, and add on

i suck at explainning, but i hope you get what i mean...

few keywords you should know are: String.length(); String.indexOf(char); for loop?

