Skip to content

Commit 9ea484e

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 929eafb + 9ec0a0c commit 9ea484e

File tree

12 files changed

+43
-23
lines changed

12 files changed

+43
-23
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3285,6 +3285,15 @@
32853285
"contributions": [
32863286
"doc"
32873287
]
3288+
},
3289+
{
3290+
"login": "SalmaAzeem",
3291+
"name": "Salma",
3292+
"avatar_url": "https://avatars.githubusercontent.com/u/121863224?v=4",
3293+
"profile": "https://github.com/SalmaAzeem",
3294+
"contributions": [
3295+
"code"
3296+
]
32883297
}
32893298
],
32903299
"contributorsPerLine": 6,

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=coverage)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
77
[![Join the chat at https://gitter.im/iluwatar/java-design-patterns](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
88
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
9-
[![All Contributors](https://img.shields.io/badge/all_contributors-360-orange.svg?style=flat-square)](#contributors-)
9+
[![All Contributors](https://img.shields.io/badge/all_contributors-361-orange.svg?style=flat-square)](#contributors-)
1010
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1111

1212
<br/>
@@ -540,6 +540,9 @@ This project is licensed under the terms of the MIT license.
540540
<td align="center" valign="top" width="16.66%"><a href="https://github.com/proceane"><img src="https://avatars.githubusercontent.com/u/62143949?v=4?s=100" width="100px;" alt="Juyeon"/><br /><sub><b>Juyeon</b></sub></a><br /><a href="#translation-proceane" title="Translation">🌍</a></td>
541541
<td align="center" valign="top" width="16.66%"><a href="https://mammadyahya.vercel.app"><img src="https://avatars.githubusercontent.com/u/66476643?v=4?s=100" width="100px;" alt="Mammad Yahyayev"/><br /><sub><b>Mammad Yahyayev</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=mammadyahyayev" title="Documentation">📖</a></td>
542542
</tr>
543+
<tr>
544+
<td align="center" valign="top" width="16.66%"><a href="https://github.com/SalmaAzeem"><img src="https://avatars.githubusercontent.com/u/121863224?v=4?s=100" width="100px;" alt="Salma"/><br /><sub><b>Salma</b></sub></a><br /><a href="https://github.com/iluwatar/java-design-patterns/commits?author=SalmaAzeem" title="Code">💻</a></td>
545+
</tr>
543546
</tbody>
544547
</table>
545548

event-aggregator/src/main/java/com/iluwatar/event/aggregator/KingsHand.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@ public void onEvent(Event e) {
4343

4444
@Override
4545
public void timePasses(Weekday day) {
46+
// This method is intentionally left empty because KingsHand does not handle time-based events directly.
47+
// It serves as a placeholder to fulfill the EventObserver interface contract.
4648
}
4749
}

filterer/src/main/java/com/iluwatar/filterer/threat/ThreatAwareSystem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
/**
3131
* Represents system that is aware of threats that are present in it.
3232
*/
33-
public interface ThreatAwareSystem {
33+
public interface ThreatAwareSystem<T extends Threat> {
3434

3535
/**
3636
* Returns the system id.
@@ -43,13 +43,13 @@ public interface ThreatAwareSystem {
4343
* Returns list of threats for this system.
4444
* @return list of threats for this system.
4545
*/
46-
List<? extends Threat> threats();
46+
List<T> threats();
4747

4848
/**
4949
* Returns the instance of {@link Filterer} helper interface that allows to covariantly
5050
* specify lower bound for predicate that we want to filter by.
5151
* @return an instance of {@link Filterer} helper interface.
5252
*/
53-
Filterer<? extends ThreatAwareSystem, ? extends Threat> filtered();
53+
Filterer<ThreatAwareSystem<T>, T> filtered();
5454

5555
}

game-loop/src/test/java/com/iluwatar/gameloop/GameLoopTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
*/
2525
package com.iluwatar.gameloop;
2626

27-
import static org.junit.jupiter.api.Assertions.assertFalse;
28-
2927
import org.junit.jupiter.api.AfterEach;
3028
import org.junit.jupiter.api.Assertions;
29+
import static org.junit.jupiter.api.Assertions.assertFalse;
3130
import org.junit.jupiter.api.BeforeEach;
3231
import org.junit.jupiter.api.Test;
3332

@@ -46,6 +45,7 @@ void setup() {
4645
gameLoop = new GameLoop() {
4746
@Override
4847
protected void processGameLoop() {
48+
throw new UnsupportedOperationException("Not supported yet.");
4949
}
5050
};
5151
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<spring-boot.version>2.7.5</spring-boot.version>
4141
<jacoco.version>0.8.12</jacoco.version>
4242
<commons-dbcp.version>1.4</commons-dbcp.version>
43-
<htmlunit.version>4.5.0</htmlunit.version>
43+
<htmlunit.version>4.7.0</htmlunit.version>
4444
<gson.version>2.11.0</gson.version>
4545
<guice.version>6.0.0</guice.version>
4646
<system-lambda.version>1.1.0</system-lambda.version>

serialized-lob/src/main/java/com/iluwatar/slob/dbservice/DatabaseService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void startupService()
9292
throws SQLException {
9393
try (var connection = dataSource.getConnection();
9494
var statement = connection.createStatement()) {
95-
if (dataTypeDb.equals("BINARY")) {
95+
if (dataTypeDb.equals(BINARY_DATA)) {
9696
statement.execute(CREATE_BINARY_SCHEMA_DDL);
9797
} else {
9898
statement.execute(CREATE_TEXT_SCHEMA_DDL);

serialized-lob/src/main/java/com/iluwatar/slob/lob/Forest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,17 @@
3737
import org.w3c.dom.Document;
3838
import org.w3c.dom.Element;
3939
import org.w3c.dom.NodeList;
40-
4140
/**
4241
* Creates an object Forest which contains animals and plants as its constituents. Animals may eat
4342
* plants or other animals in the forest.
4443
*/
44+
45+
4546
@Data
4647
@NoArgsConstructor
4748
@AllArgsConstructor
4849
public class Forest implements Serializable {
49-
50+
public static final String HORIZONTAL_DIVIDER = "\n--------------------------\n";
5051
private String name;
5152
private Set<Animal> animals = new HashSet<>();
5253
private Set<Plant> plants = new HashSet<>();
@@ -105,16 +106,16 @@ public String toString() {
105106
sb.append("Forest Name = ").append(name).append("\n");
106107
sb.append("Animals found in the ").append(name).append(" Forest: \n");
107108
for (Animal animal : animals) {
108-
sb.append("\n--------------------------\n");
109+
sb.append(HORIZONTAL_DIVIDER);
109110
sb.append(animal.toString());
110-
sb.append("\n--------------------------\n");
111+
sb.append(HORIZONTAL_DIVIDER);
111112
}
112113
sb.append("\n");
113114
sb.append("Plants in the ").append(name).append(" Forest: \n");
114115
for (Plant plant : plants) {
115-
sb.append("\n--------------------------\n");
116+
sb.append(HORIZONTAL_DIVIDER);
116117
sb.append(plant.toString());
117-
sb.append("\n--------------------------\n");
118+
sb.append(HORIZONTAL_DIVIDER);
118119
}
119120
return sb.toString();
120121
}

type-object/src/main/java/com/iluwatar/typeobject/App.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
2+
* This project is licensed under the MIT license. Module model-view-viewmodel
3+
* is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
34
*
45
* The MIT License
56
* Copyright © 2014-2022 Ilkka Seppälä
@@ -27,12 +28,12 @@
2728
import lombok.extern.slf4j.Slf4j;
2829

2930
/**
30-
* <p>Type object pattern is the pattern we use when the OOP concept of creating a base class and
31+
* Type object pattern is the pattern we use when the OOP concept of creating a base class and
3132
* inheriting from it just doesn't work for the case in hand. This happens when we either don't know
3233
* what types we will need upfront, or want to be able to modify or add new types conveniently w/o
3334
* recompiling repeatedly. The pattern provides a solution by allowing flexible creation of required
34-
* objects by creating one class, which has a field which represents the 'type' of the object.</p>
35-
* <p>In this example, we have a mini candy-crush game in action. There are many different candies
35+
* objects by creating one class, which has a field which represents the 'type' of the object.
36+
* In this example, we have a mini candy-crush game in action. There are many different candies
3637
* in the game, which may change over time, as we may want to upgrade the game. To make the object
3738
* creation convenient, we have a class {@link Candy} which has a field name, parent, points and
3839
* Type. We have a json file {@link candy} which contains the details about the candies, and this is
@@ -41,7 +42,7 @@
4142
* how crushing can be done, how the matrix is to be reconfigured and how points are to be gained.
4243
* The {@link CellPool} class is a pool which reuses the candy cells that have been crushed instead
4344
* of making new ones repeatedly. The {@link CandyGame} class has the rules for the continuation of
44-
* the game and the {@link App} class has the game itself.</p>
45+
* the game and the {@link App} class has the game itself.
4546
*/
4647

4748
@Slf4j

type-object/src/main/java/com/iluwatar/typeobject/CandyGame.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import java.util.ArrayList;
2929
import java.util.List;
3030
import lombok.extern.slf4j.Slf4j;
31+
import org.slf4j.Logger;
32+
import org.slf4j.LoggerFactory;
3133

3234
/**
3335
* The CandyGame class contains the rules for the continuation of the game and has the game matrix
@@ -37,7 +39,6 @@
3739
@Slf4j
3840
@SuppressWarnings("java:S3776") //"Cognitive Complexity of methods should not be too high"
3941
public class CandyGame {
40-
4142
Cell[][] cells;
4243
CellPool pool;
4344
int totalPoints;
@@ -85,17 +86,20 @@ List<Cell> adjacentCells(int y, int x) {
8586
if (x == 0) {
8687
adjacent.add(this.cells[y][1]);
8788
}
88-
if (y == cells.length - 1) {
89+
if (y == cells.length - 1 && cells.length > 1) {
8990
adjacent.add(this.cells[cells.length - 2][x]);
9091
}
91-
if (x == cells.length - 1) {
92+
93+
if (x == cells.length - 1 && cells.length > 1) {
9294
adjacent.add(this.cells[y][cells.length - 2]);
9395
}
96+
97+
9498
if (y > 0 && y < cells.length - 1) {
9599
adjacent.add(this.cells[y - 1][x]);
96100
adjacent.add(this.cells[y + 1][x]);
97101
}
98-
if (x > 0 && x < cells.length - 1) {
102+
if (y >= 0 && y < cells.length && x > 0 && x < cells[y].length - 1) {
99103
adjacent.add(this.cells[y][x - 1]);
100104
adjacent.add(this.cells[y][x + 1]);
101105
}

0 commit comments

Comments
 (0)