-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
83 changed files
with
14,215 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>homework2</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
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,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.7 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.7 |
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,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<component jdk="JavaSE-1.7"> | ||
<exclude-output/> | ||
<contentEntry url="file://$MODULE_DIR$"/> | ||
</component> |
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,2 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module classpath="eclipse" classpath-dir="$MODULE_DIR$" type="JAVA_MODULE" version="4" /> |
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,94 @@ | ||
package gui; | ||
|
||
import hw2.ScoreCalculator; | ||
import hw2.Words; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.util.Random; | ||
|
||
import javax.swing.JFrame; | ||
import javax.swing.JOptionPane; | ||
import javax.swing.JPanel; | ||
import javax.swing.SwingUtilities; | ||
|
||
import util.PermutationGenerator; | ||
|
||
/** | ||
* Main class for starting an instance of <code>WordGameUI</code>. | ||
*/ | ||
public class UIMain | ||
{ | ||
/** | ||
* Entry point. | ||
*/ | ||
public static void main(String[] args) | ||
{ | ||
// Edit here to use a different word file | ||
final String filename = "words2.txt"; | ||
|
||
// Edit here to change the seed for the WordScrambler's | ||
// random number generator. For unpredictable behavior, | ||
// use the system time as a seed: | ||
final int seed = (int) System.currentTimeMillis(); | ||
//final int seed = 42; | ||
|
||
// Boilerplate code for safely starting up a Swing application | ||
// on the event-handling thread. | ||
Runnable r = new Runnable() | ||
{ | ||
public void run() | ||
{ | ||
createAndShow(filename, seed); | ||
} | ||
}; | ||
SwingUtilities.invokeLater(r); | ||
} | ||
|
||
/** | ||
* Helper method for creating and starting the UI. | ||
* @param filename | ||
* filename for word list | ||
* @param seed | ||
* seed for random number generator in the WordScrambler | ||
*/ | ||
private static void createAndShow(String filename, int seed) | ||
{ | ||
// the main window for this application | ||
JFrame frame = new JFrame("Com S 227 Word Scramble"); | ||
|
||
try | ||
{ | ||
// this may throw FileNotFoundException | ||
Words wordList = new Words(filename); | ||
|
||
// scoring based on | ||
// 5 seconds per letter | ||
// 5 second penalty for a letter hint | ||
// 1/10 second penalty for rescrambling | ||
// 1-second penalty for submitting an incorrect guess | ||
ScoreCalculator calc = new ScoreCalculator(5000, 5000, 100, 1000); | ||
Random rand = new Random(seed); | ||
PermutationGenerator pg = new PermutationGenerator(rand); | ||
|
||
// construct the main game panel and add it to the frame | ||
JPanel mainPanel = new WordGameUI(calc, wordList, rand, pg); | ||
frame.getContentPane().add(mainPanel); | ||
|
||
// size the frame based on the preferred size of the mainPanel | ||
frame.pack(); | ||
|
||
// make sure it closes when you click the close button on the window | ||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
|
||
// rock and roll... | ||
frame.setVisible(true); | ||
} | ||
catch (FileNotFoundException e) | ||
{ | ||
JOptionPane.showMessageDialog(frame, "Unable to open word file: " + e.getMessage()); | ||
frame.dispose(); | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.