-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add New Support for Playing Scramble
- Loading branch information
Showing
5 changed files
with
137 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package example.data; | ||
|
||
import java.io.Serializable; | ||
|
||
public class PlayResults extends Object implements Serializable { | ||
/** | ||
* serialVersionUID | ||
*/ | ||
private static final long serialVersionUID = 8808259418494243920L; | ||
private Word selectedWord; | ||
private int score; | ||
private String scrambledWord; | ||
private int numWrong; | ||
private int numCorrect; | ||
private String message; | ||
public PlayResults (Word aWord) { | ||
init(aWord); | ||
} | ||
private void init(Word aWord) { | ||
score = 0; | ||
selectedWord = aWord; | ||
scrambledWord = selectedWord.scrambled(); | ||
numCorrect = 0; | ||
numWrong = 0; | ||
message = "" ; | ||
} | ||
public Word getSelectedWord() { | ||
return selectedWord; | ||
} | ||
public void setSelectedWord(Word selectedWord) { | ||
this.selectedWord = selectedWord; | ||
this.scrambledWord = selectedWord.scrambled(); | ||
this.message = ""; | ||
} | ||
public int getScore() { | ||
return score; | ||
} | ||
public void setScore(int score) { | ||
this.score = score; | ||
} | ||
public String getScrambledWord() { | ||
return scrambledWord; | ||
} | ||
public void setScrambledWord(String scrambledWord) { | ||
this.scrambledWord = scrambledWord; | ||
} | ||
public int getNumWrong() { | ||
return numWrong; | ||
} | ||
public void setNumWrong(int numWrong) { | ||
this.numWrong = numWrong; | ||
} | ||
public int getNumCorrect() { | ||
return numCorrect; | ||
} | ||
public void setNumCorrect(int numCorrect) { | ||
this.numCorrect = numCorrect; | ||
} | ||
public static long getSerialversionuid() { | ||
return serialVersionUID; | ||
} | ||
public String getMessage() { | ||
return message; | ||
} | ||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
public void correct() { | ||
++numCorrect; | ||
setMessage("You are correct !!"); | ||
setScore(getScore()+getSelectedWord().getPoints().intValue()); | ||
} | ||
public void wrong() { | ||
++numWrong; | ||
setMessage("You are incorrect !!"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters