📍Use lombok, reformat, and optimize the code (#1560)

* Use lombok, reformat, and optimize the code

* Fix merge conflicts and some sonar issues

Co-authored-by: va1m <va1m@email.com>
This commit is contained in:
va1m
2021-03-13 13:19:21 +01:00
committed by GitHub
parent 0e26a6adb5
commit 5cf2fe009b
681 changed files with 2472 additions and 4966 deletions

View File

@ -23,11 +23,9 @@
package com.iluwatar.typeobject;
import java.io.FileNotFoundException;
import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
import org.json.simple.parser.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* <p>Type object pattern is the pattern we use when the OOP concept of creating a base class and
@ -47,10 +45,9 @@ import org.slf4j.LoggerFactory;
* the game and the {@link App} class has the game itself.</p>
*/
@Slf4j
public class App {
private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
/**
* Program entry point.
*

View File

@ -23,10 +23,15 @@
package com.iluwatar.typeobject;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
/**
* The Candy class has a field type, which represents the 'type' of candy. The objects are created
* by parsing the candy.json file.
*/
@Getter(AccessLevel.PACKAGE)
public class Candy {
enum Type {
@ -37,6 +42,8 @@ public class Candy {
String name;
Candy parent;
String parentName;
@Setter
private int points;
private final Type type;
@ -48,15 +55,4 @@ public class Candy {
this.parentName = parentName;
}
int getPoints() {
return this.points;
}
void setPoints(int a) {
this.points = a;
}
Type getType() {
return this.type;
}
}

View File

@ -26,18 +26,16 @@ package com.iluwatar.typeobject;
import com.iluwatar.typeobject.Candy.Type;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;
/**
* The CandyGame class contains the rules for the continuation of the game and has the game matrix
* (field 'cells') and totalPoints gained during the game.
*/
@Slf4j
public class CandyGame {
private static final Logger LOGGER = LoggerFactory.getLogger(CandyGame.class);
Cell[][] cells;
CellPool pool;
int totalPoints;

View File

@ -24,28 +24,20 @@
package com.iluwatar.typeobject;
import com.iluwatar.typeobject.Candy.Type;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
/**
* The Cell object is what the game matrix is made of and contains the candy which is to be crushed
* or collected as reward.
*/
@AllArgsConstructor
@NoArgsConstructor
public class Cell {
Candy candy;
int positionX;
int positionY;
Cell(Candy candy, int positionX, int positionY) {
this.candy = candy;
this.positionX = positionX;
this.positionY = positionY;
}
Cell() {
this.candy = null;
this.positionX = 0;
this.positionY = 0;
}
void crush(CellPool pool, Cell[][] cellMatrix) {
//take out from this position and put back in pool
pool.addNewCell(this);