In this new release, the main objective was to extract the utility methods and input/output methods from the classes to new ones. Doing that, now I have more classes and packages, but also I reduced the length, clarity and complexity of some of them.
The methods that contain user input, now are all together in the UserInput
class, inside the io
package.
The String
and color utility methods now are inside util
package.
I "static-call" all of them when it's necessary.
I did set the same structure for Catalan and English version, so now there are 2 packages: catalan
and english
, instead of using the root to store the English one and then the Catalan one in a package apart. Also, the App
class, which contains the main method, is in the root not in english
or catalan
packages.
Doing that, I make sure that English version can be run without Catalan one, and back. Before, Catalan version depended on English one.
- Note that in the
App
class, theScanner
from the English version is used. Only in that case, the English version is required.
AI
now extends Bot
. AI
is a type of bot, it's not a record anymore. Now it overrides throwCard()
method from Bot
. With those changes, in the Bot
, AI
and Game
classes is much clearer to see how it works. For example, in the Game
class I create a Human
and, depending on what the user chooses, a Bot
or an AI
. All extend from Player
.
Also, I refactored the code and I made some improvements removing code redundancies and replacing manually written code with calls to JDK
utility methods, which are already pre-programmed, are part of the JDK
and they do the same as my code, but faster and using less resources (I guess).