Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
darkhyper24 committed Dec 7, 2024
2 parents 929eafb + 9ec0a0c commit 9ea484e
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 23 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -3285,6 +3285,15 @@
"contributions": [
"doc"
]
},
{
"login": "SalmaAzeem",
"name": "Salma",
"avatar_url": "https://avatars.githubusercontent.com/u/121863224?v=4",
"profile": "https://github.com/SalmaAzeem",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 6,
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=iluwatar_java-design-patterns&metric=coverage)](https://sonarcloud.io/dashboard?id=iluwatar_java-design-patterns)
[![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)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-360-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-361-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

<br/>
Expand Down Expand Up @@ -540,6 +540,9 @@ This project is licensed under the terms of the MIT license.
<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>
<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>
</tr>
<tr>
<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>
</tr>
</tbody>
</table>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ public void onEvent(Event e) {

@Override
public void timePasses(Weekday day) {
// This method is intentionally left empty because KingsHand does not handle time-based events directly.
// It serves as a placeholder to fulfill the EventObserver interface contract.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/**
* Represents system that is aware of threats that are present in it.
*/
public interface ThreatAwareSystem {
public interface ThreatAwareSystem<T extends Threat> {

/**
* Returns the system id.
Expand All @@ -43,13 +43,13 @@ public interface ThreatAwareSystem {
* Returns list of threats for this system.
* @return list of threats for this system.
*/
List<? extends Threat> threats();
List<T> threats();

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@
*/
package com.iluwatar.gameloop;

import static org.junit.jupiter.api.Assertions.assertFalse;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import static org.junit.jupiter.api.Assertions.assertFalse;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -46,6 +45,7 @@ void setup() {
gameLoop = new GameLoop() {
@Override
protected void processGameLoop() {
throw new UnsupportedOperationException("Not supported yet.");
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<spring-boot.version>2.7.5</spring-boot.version>
<jacoco.version>0.8.12</jacoco.version>
<commons-dbcp.version>1.4</commons-dbcp.version>
<htmlunit.version>4.5.0</htmlunit.version>
<htmlunit.version>4.7.0</htmlunit.version>
<gson.version>2.11.0</gson.version>
<guice.version>6.0.0</guice.version>
<system-lambda.version>1.1.0</system-lambda.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void startupService()
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);
Expand Down
13 changes: 7 additions & 6 deletions serialized-lob/src/main/java/com/iluwatar/slob/lob/Forest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@
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<>();
Expand Down Expand Up @@ -105,16 +106,16 @@ public String toString() {
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();
}
Expand Down
11 changes: 6 additions & 5 deletions type-object/src/main/java/com/iluwatar/typeobject/App.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* This project is licensed under the MIT license. Module model-view-viewmodel is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
* This project is licensed under the MIT license. Module model-view-viewmodel
* is using ZK framework licensed under LGPL (see lgpl-3.0.txt).
*
* The MIT License
* Copyright © 2014-2022 Ilkka Seppälä
Expand Down Expand Up @@ -27,12 +28,12 @@
import lombok.extern.slf4j.Slf4j;

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

@Slf4j
Expand Down
12 changes: 8 additions & 4 deletions type-object/src/main/java/com/iluwatar/typeobject/CandyGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.ArrayList;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* The CandyGame class contains the rules for the continuation of the game and has the game matrix
Expand All @@ -37,7 +39,6 @@
@Slf4j
@SuppressWarnings("java:S3776") //"Cognitive Complexity of methods should not be too high"
public class CandyGame {

Cell[][] cells;
CellPool pool;
int totalPoints;
Expand Down Expand Up @@ -85,17 +86,20 @@ List<Cell> adjacentCells(int y, int x) {
if (x == 0) {
adjacent.add(this.cells[y][1]);
}
if (y == cells.length - 1) {
if (y == cells.length - 1 && cells.length > 1) {
adjacent.add(this.cells[cells.length - 2][x]);
}
if (x == cells.length - 1) {

if (x == cells.length - 1 && cells.length > 1) {
adjacent.add(this.cells[y][cells.length - 2]);
}


if (y > 0 && y < cells.length - 1) {
adjacent.add(this.cells[y - 1][x]);
adjacent.add(this.cells[y + 1][x]);
}
if (x > 0 && x < cells.length - 1) {
if (y >= 0 && y < cells.length && x > 0 && x < cells[y].length - 1) {
adjacent.add(this.cells[y][x - 1]);
adjacent.add(this.cells[y][x + 1]);
}
Expand Down

0 comments on commit 9ea484e

Please sign in to comment.