mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-06-01 20:12:55 +00:00
* fix: add UnsupportedOperationException in KingsHand and GameLoopTest * refactor: update DatabaseService to use constant for BINARY_DATA and remove obsolete test files * refactor: update timePasses method in KingsHand * refactor CandyGame.java * refactor: simplify boundary checks in CandyGame * feat: add getters for type and points in Candy class and initialize logger in CandyGame * remove class and logger initialization in CandyGame * Modify CandyGame.java * fix Checkstyle violations * Remove generic wildcard type in ThreatAwareSystem
This commit is contained in:
@@ -92,7 +92,7 @@ public class DatabaseService {
|
||||
throws SQLException {
|
||||
try (var connection = dataSource.getConnection();
|
||||
var statement = connection.createStatement()) {
|
||||
if (dataTypeDb.equals("BINARY")) {
|
||||
if (dataTypeDb.equals(BINARY_DATA)) {
|
||||
statement.execute(CREATE_BINARY_SCHEMA_DDL);
|
||||
} else {
|
||||
statement.execute(CREATE_TEXT_SCHEMA_DDL);
|
||||
|
||||
@@ -37,16 +37,17 @@ import lombok.NoArgsConstructor;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
/**
|
||||
* Creates an object Forest which contains animals and plants as its constituents. Animals may eat
|
||||
* plants or other animals in the forest.
|
||||
*/
|
||||
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Forest implements Serializable {
|
||||
|
||||
public static final String HORIZONTAL_DIVIDER = "\n--------------------------\n";
|
||||
private String name;
|
||||
private Set<Animal> animals = new HashSet<>();
|
||||
private Set<Plant> plants = new HashSet<>();
|
||||
@@ -105,16 +106,16 @@ public class Forest implements Serializable {
|
||||
sb.append("Forest Name = ").append(name).append("\n");
|
||||
sb.append("Animals found in the ").append(name).append(" Forest: \n");
|
||||
for (Animal animal : animals) {
|
||||
sb.append("\n--------------------------\n");
|
||||
sb.append(HORIZONTAL_DIVIDER);
|
||||
sb.append(animal.toString());
|
||||
sb.append("\n--------------------------\n");
|
||||
sb.append(HORIZONTAL_DIVIDER);
|
||||
}
|
||||
sb.append("\n");
|
||||
sb.append("Plants in the ").append(name).append(" Forest: \n");
|
||||
for (Plant plant : plants) {
|
||||
sb.append("\n--------------------------\n");
|
||||
sb.append(HORIZONTAL_DIVIDER);
|
||||
sb.append(plant.toString());
|
||||
sb.append("\n--------------------------\n");
|
||||
sb.append(HORIZONTAL_DIVIDER);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user