Programming Assignment 09
Deadline: December 04, 2024 – Wednesday, 11:30pm
This assignment is part 2 of a 2-part assignment. In the firs part you wrote code to create a word search grid. In this assignment you will write code for a user to play that game.
Game play
Reuse your code for the previous assignment, and once you have a word grid (previous assignment) go into a REPL (read–eval–print loop) to read in commands from the player. With each successful word information (word, location, and orientation) entered by the player, the word will be removed from the grid and replaced with *
(careful to not remove characters that belong to overlapping words that have not been found yet).
Example of game play (removing a word with overlapping characters):
a b c d e f g h i j k l m n o p q r s t
00 M Q R K A J M D X L H O I U J S W U R K
01 N V X C R O I S S A N T M U V J Q U K V
02 J E V O W R M I K T W O M N J F E Q O Y
03 I X Y F A G D Y B G B T A L A C B R Y E
04 P W P F I Q G X D A R V E B Y P D P E G
05 C K G E A H G H S C O N E A X E K B L X
06 I P D E O O P Y Y R W Q X N P F F I P R
07 R X E R F X X V X V N T C H F F V W N O
08 S H B O B D O W T E I W R M F A U Y A Q
09 F A M A Z I N G P X E U B D P V W H S U
10 A F C F O T I J V O R C P E Y W M N M I
11 H K U Y O G B E K N V W Y S H H O U S E
12 Q N V D M K K C C D C R N A U V U G H F
13 Y W K V G I H N L O T C W G A D S L Y E
14 T M Y I F E L A H J E M S D D A E H Y M
15 H M B I J N H K T C O F Y P P I L M F K
16 V N M H A T Y Y U G O H N B X G B Y P A
17 U N G A R X W D F U X F N J W L M D Y R
18 Y B U Y B C K T N T H N E K M T Q H S N
19 K F L F H N S Y X R Q W V A G V G G Y K
Enter word found: croissant
Enter x: 1
Enter y: d
[H]orizontal [V]ertical [D]iagonal? h
croissant removed
a b c d e f g h i j k l m n o p q r s t
00 J E T E X Q O E W B H V U I D C L D G U
01 H C U C * * * * * * * * H W S K P E K H
02 L B P O B O D S V G S X O N O S X G E I
03 W N T F W C W Y I D B T X R A B P A H U
04 B H K F F T D T D W R L E G L P X I I B
05 E G R E Y N K C S C O N E A J G K G K A
06 K L H E V D F H T L W T E U S W J I U G
07 A G A H K B X G O F N D H J H S C S N N
08 D I D H T B L D A Y I E C U C W M M X F
09 C A M A Z I N G X S E D F O W R V B K A
10 J F D P O L V M X G C J Y L G J M T B D
11 X D U Q O D I L E B G X P B P H O U S E
12 W Y D D M G D C Q E U R A B M Y U X Q Y
13 N S Q F G I B E Y M E C A L A N S X Q K
14 U F Q O R E L H H T S L N E P B E C H Y
15 Y S C P P C E K M V Y N K K F I P J J N
16 L G X S J X L U B B B G H W D T D J B M
17 I K P X Q C F D D W Y F D H G W T D O Q
18 J C W R T W L B N V M Q Y M N O K E P L
19 W S Y K X O I R J T B I K O N K Q S P N
A few more examples, with another word found, and a word missed:
Enter word found: fudge
Enter x: 10
Enter y: b
[H]orizontal [V]ertical [D]iagonal? d
fudge removed
a b c d e f g h i j k l m n o p q r s t
00 T B R G B O A W H P A N K P D W J U A Y
01 U F Q C * * * * * * * * W O K N Y Y J I
02 Q H C O F B V J Y L B A X N I V N J V B
03 F M B F N I Q R E Q B T N X A P E P K L
04 S Q O F D L Y G M Y R S E M B P C U J E
05 X K M E I E L H S C O N E A K X K G N A
06 K X B E A M Y U M W W B N G U H E I A M
07 U G M V T T T I U B N K T I O T Y V N U
08 A Q T X E B A N I E I W B G N S G O X F
09 A A M A Z I N G E X E S E N L D U T O L
10 P * Q H O E A M B M Q U G Q G R M D X F
11 H C * P O L T Y H G H K X G F H O U S E
12 G X J * M B R X L G W U I C F K U U B I
13 Y N K S * I B R L A Q L A L C D S E U X
14 Y U E K L * L K J N C F I V D G E R J X
15 M I K E D K G K E V T D H L Y U L G Y N
16 E P B A G N L D U I E E L T P U K F P U
17 B P P Q V U S X W Y P V Q S E T H M A W
18 V B N U S J J W U O H U L F X V B Y P G
19 P R T L W G X G R D U S D Q Q E Y G A N
Enter word found: scone
Enter x: 5
Enter y: j
[H]orizontal [V]ertical [D]iagonal? h
scone not found
When one of the information values does not match (for scone, above, the correct y
is i
not j
) a message should be printed telling the player the word was not found.
Game Over
When all words have been found, print out All words found!
and quit the game.
a b c d e f g h i j k l m n o p q r s t
00 B J M H D S X I U I U U * A * C M H V J
01 A A A K N F I X X N G F M * D * U N L R
02 A I N X Q Q G K S H I F U Q * E * X Y B
03 X * * * * * * * C W H L E L R * V O P M
04 D X N L E * F * B B X U G D K E N X D I
05 B Q Y I D * * * * V * P D S O K D X D U
06 H Q C G D * I * I X U * G K F G V P Y W
07 U L V Y P * P * L I M Y * X V D M T F D
08 W T * R L * G * R N V N R * F H R B V Q
09 R I G * R D D I Q J F B I V * F R Y K A
10 B W Q J * N A S L E K K Q V Q D O Y X T
11 J T G Q X * B W M W * * * * * G R C E J
12 T T I B K R * A H X A Q V C O G F Y O B
13 Y E Q D E T J * P * * * * * * * * * T S
14 R D A B W R H K * * E J B H R Q M G I J
15 Y E P R H L H P A * R P O * X I X U Q E
16 I G T D H M H B X * V W M V * S N D W S
17 C E V R P T G T O * B F C M H * L F O S
18 G L F T R T W B P * A Y H X T L * Y E J
19 X G L G R C D W V O X K H J M D N * T R
All words found!
Keep the name of your java class with the main method as WordSearch.java
.
Submission
Submit your code to gradescope (the autograder will not run) and a link to your video (if you don’t submit a video, you will get a zero on this assignment). Your video should be less than 5 minutes long and it should show all words being found (the game should end).
Your video should show your name and the current semester information.
Here’s an example:
Decomposition
Points will be taken off for copy, pasted, and edited code that should have been encapsulated in a method.
This program should use fewer than 5 .java files. But at least 3 .java files Each of these files should be (<300 lines). Do NOT include hard code any specific words at specific coordinates.
Each method should be less than 30 lines. This INCLUDES comments, but not the method header. It is easier to read a function if it can all fit on one screen.
Code Clarity
YOU should be able to read, understand, and explain your own code to someone else a couple days after you wrote it.
- No magic numbers
- No methods written to just get the test cases to work
There needs to be a balance between no comments in the body of the methods and a comment for every line in the program. Either extreme will result in points off.
The file header should include instructions on how someone would use this program. To use the program, one would need to know the input file format. One would also need to know the command line arguments that should be passed to the program.
Use meaningful variable names. Loop iterators can be simple (i for integers, s for strings, n for numbers, etc.).
The clearest code examples will be anonymously shown in class.
The most obfuscated code examples will be anonymously shown in class with suggestions for improvement.