LAB Activity 04082026
2026-04-01 20:23
Tags: #java
Author: Duke Hsu
Key topic / concepts
- One dimensional arrays
- String class and string comparison
- charAt() , valueof(), equals, length(), equalsIgnoreCase() ,toLowerCase()
- Looping statements(for, while)
- Condition statements(if, if-else)
- Random number generation
- Classes, objects, attributes, and methods.
Ramdon
- java.util.Random;
- Random class is used to generate pseudo-random numbers in java.
- In this case, we can use
rand.nextInt(wordList.length)to choose which word we get from an array .
Random word Example:
1 2 3 4 5 6 7 | |
Code
Main Class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
HangmanGame Class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
Output
Output 1
Output 2
**Output 3 **


