Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Scrabble Program Help
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
scottyrush13




PostPosted: Thu Nov 29, 2007 8:34 am   Post subject: 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.



ScrabbleTools.java
 Description:

Download
 Filename:  ScrabbleTools.java
 Filesize:  1.59 KB
 Downloaded:  159 Time(s)


ScrabbleScoring.java
 Description:

Download
 Filename:  ScrabbleScoring.java
 Filesize:  1.73 KB
 Downloaded:  166 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
scottyrush13




PostPosted: Thu Nov 29, 2007 9:45 am   Post subject: 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




PostPosted: Thu Nov 29, 2007 11:01 am   Post subject: 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
code:
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?
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: