Skip to content

Commit

Permalink
solve button
Browse files Browse the repository at this point in the history
  • Loading branch information
pluginas committed Apr 16, 2023
1 parent 904c615 commit 3bb1f5f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 100 deletions.
21 changes: 12 additions & 9 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 19 additions & 5 deletions src/main/java/app/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
import java.util.ArrayList;
import java.util.concurrent.ThreadLocalRandom;

/**
* Класс задачи
*/


/**
* Класс задачи
Expand Down Expand Up @@ -55,6 +53,11 @@ public class Task {
*/
protected CoordinateSystem2i lastWindowCS;

/**
* Флаг, решена ли задача
*/
private boolean solved;

/**
* Задача
*
Expand Down Expand Up @@ -116,16 +119,17 @@ public void click(Vector2i pos, MouseButton mouseButton) {
}
}


/**
* Добавить точку
*
* @param pos положение
* @param pointSet множество
*/
public void addPoint(Vector2d pos, Point.PointSet pointSet) {
solved = false;
Point newPoint = new Point(pos, pointSet);
points.add(newPoint);
// Добавляем в лог запись информации
PanelLog.info("точка " + newPoint + " добавлена в " + newPoint.getSetName());
}

Expand Down Expand Up @@ -165,19 +169,29 @@ public void addRandomPoints(int cnt) {
*/
public void clear() {
points.clear();
solved = false;
}

/**
* Решить задачу
*/
public void solve() {
solved = true;
PanelLog.warning("Вызван метод solve()\n Пока что решения нет");
}
/**
* Отмена решения задачи
*/
public void cancel() {

solved = false;
}
/**
* проверка, решена ли задача
*
* @return флаг
*/
public boolean isSolved() {
return solved;
}


Expand Down
10 changes: 9 additions & 1 deletion src/main/java/panels/PanelControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,17 @@ public PanelControl(
window, false, backgroundColor, PANEL_PADDING,
6, 7, 3, 6, 3, 1, "Решить",
true, true);

solve.setOnClick(() -> {
PanelRendering.task.solve();
if (!PanelRendering.task.isSolved()) {
PanelRendering.task.solve();
solve.text = "Сбросить";
} else {
cancelTask();
}
window.requestFrame();
});

buttons.add(solve);


Expand Down
86 changes: 1 addition & 85 deletions src/main/resources/conf.json
Original file line number Diff line number Diff line change
@@ -1,85 +1 @@
{
"@class": "app.Task",
"ownCS": {
"min": {
"x": -10.0,
"y": -10.0
},
"max": {
"x": 10.0,
"y": 10.0
}
},
"points": [
{
"pos": {
"x": 0.3448275862068968,
"y": -9.310344827586206
},
"setType": "FIRST_SET"
},
{
"pos": {
"x": -10.0,
"y": -6.551724137931035
},
"setType": "FIRST_SET"
},
{
"pos": {
"x": -10.0,
"y": 1.7241379310344822
},
"setType": "FIRST_SET"
},
{
"pos": {
"x": -5.172413793103448,
"y": 6.551724137931036
},
"setType": "FIRST_SET"
},
{
"pos": {
"x": -3.1034482758620694,
"y": 1.7241379310344822
},
"setType": "SECOND_SET"
},
{
"pos": {
"x": -1.0344827586206904,
"y": 0.3448275862068968
},
"setType": "FIRST_SET"
},
{
"pos": {
"x": 5.862068965517242,
"y": -7.931034482758621
},
"setType": "SECOND_SET"
},
{
"pos": {
"x": -4.482758620689655,
"y": -4.482758620689655
},
"setType": "FIRST_SET"
},
{
"pos": {
"x": -9.310344827586206,
"y": 0.3448275862068968
},
"setType": "FIRST_SET"
},
{
"pos": {
"x": 5.172413793103448,
"y": 2.413793103448276
},
"setType": "SECOND_SET"
}
]
}
{"@class":"app.Task","ownCS":{"min":{"x":-10.0,"y":-10.0},"max":{"x":10.0,"y":10.0}},"points":[],"solved":false}

0 comments on commit 3bb1f5f

Please sign in to comment.