Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CPSC219W_Assignment2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Yerdana Jengiskhan
CPSC219W_Assignment2
Commits
60e80d7b
Commit
60e80d7b
authored
1 month ago
by
Yerdana Jengiskhan
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
e1071ef9
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
WordGame.java
+29
-0
29 additions, 0 deletions
WordGame.java
with
29 additions
and
0 deletions
WordGame.java
0 → 100644
+
29
−
0
View file @
60e80d7b
// 🎮 WordGame.java - The core logic of our word-guessing adventure!
// Author: Yerdana Jengiskhan
// Course: CPSC219
// Reference: https://www.nytimes.com/games/wordle/index.html(Wordle Game)
import
java.util.Random
;
import
java.util.Set
;
public
class
WordGame
{
private
String
secretWord
;
private
Set
<
String
>
validWords
;
public
WordGame
(
Set
<
String
>
wordList
)
{
this
.
validWords
=
wordList
;
pickRandomWord
();
}
private
void
pickRandomWord
()
{
int
index
=
new
Random
().
nextInt
(
validWords
.
size
());
this
.
secretWord
=
(
String
)
validWords
.
toArray
()[
index
];
}
public
boolean
isCorrectGuess
(
String
guess
)
{
return
guess
.
equalsIgnoreCase
(
secretWord
);
}
public
String
getSecretWord
()
{
return
secretWord
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment