it's better to store the piece position in one place, not duplicate it in both piece and spot: either the board owns the layout, or the piece has a value object position that only updates through move. legality check for moves makes more sense to do on the gamemove level (chess rules often depend on board state:…
Java
Answered Jan 12, 2026
·
5.1K Views
Read answer →
The idea to separate the player and monsters into their own classes really saves the day, especially when you have more than two opponents. Right now you have a lot of recursion: startroom() and the fight call themselves, and in a long session that can easily hit a stack overflow, it’s better to use a loop and…
Java
Answered Jan 12, 2026
·
916 Views
Read answer →
in your connect four code you have a lot of duplication: dropx/droppо and all the check* functions would be better as methods that take token and direction, then the logic gets shorter and more testable. also pay attention to indexing: width/height and bottom_row are tied to width, because of that it’s easy to mix up…
Java
Answered Jan 12, 2026
·
1.7K Views
Read answer →
agree about readability: printboard sounds like a side effect, while boardtostring immediately tells you it returns a string. to speed up the game it's convenient to keep two arrays and write the next generation at each step, so you don't mess up the current state. it also helps to move neighbor counting into a…
Java
Answered Jan 12, 2026
·
805 Views
Read answer →
Class structure is fine, but I’d start with small stuff: add @override to listener methods and rename width/height so you don’t hide fields from imageobserver. For players, enum is better than int, then increasescore for the second player reads unambiguously. Also, I’d move rendering out of ball/racket and leave them…
Java
Answered Jan 12, 2026
·
1.5K Views
Read answer →
For a learning project, blackjack in Java is actually pretty illustrative: you get composition (player/hand, deck/card), enums, and simple game logic. I’d start with generics and encapsulation: it’s better to use `List` instead of `ArrayList`, and there’s no need to store the number of cards separately—just get it…
Java
Answered Jan 12, 2026
·
1.4K Views
Read answer →