Skip to content
Snippets Groups Projects
Commit 3888a3e7 authored by KALLEL Mohamed ali's avatar KALLEL Mohamed ali
Browse files

task 1

parent f4d390d4
No related branches found
No related tags found
No related merge requests found
Showing
with 99 additions and 22 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane fx:id="Fire" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Spinner fx:id="fire" editable="true" layoutX="111.0" layoutY="67.0" prefHeight="25.0" prefWidth="363.0" />
<Label layoutX="111.0" layoutY="50.0" text="Fire" />
<Label layoutX="111.0" layoutY="103.0" text="Fire Fighter" />
</children>
</AnchorPane>
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="controller.controllerMenu"
prefHeight="400.0" prefWidth="600.0">
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="controller.controllerMenu">
<children>
<Button layoutX="36.0" layoutY="119.0" mnemonicParsing="false" prefHeight="106.0" prefWidth="259.0" text="firefiter" />
<Button layoutX="321.0" layoutY="119.0" mnemonicParsing="false" prefHeight="106.0" prefWidth="259.0" text="virus" />
<Button layoutX="193.0" layoutY="279.0" mnemonicParsing="false" prefHeight="56.0" prefWidth="231.0" text="play" />
<Button layoutX="541.0" layoutY="14.0" mnemonicParsing="false" prefHeight="41.0" prefWidth="45.0" text="setting" />
<Button layoutX="14.0" layoutY="14.0" mnemonicParsing="false" prefHeight="35.0" prefWidth="96.0" text="exit" />
</children>
</AnchorPane>
No preview for this file type
......@@ -14,7 +14,7 @@ import java.net.URL;
import java.util.Map;
public class SimulatorApplication extends javafx.application.Application {
private static final String VIEW_RESOURCE_PATH = "/view/fireFigtherView/fireFigtherBord.fxml";
private static final String VIEW_RESOURCE_PATH = "/view/fireFigtherView/putElementCount.fxml";
private static final String APP_NAME = "Firefighter simulator";
private static final int ROW_COUNT = 20;
......@@ -45,12 +45,12 @@ public class SimulatorApplication extends javafx.application.Application {
private void initializeInitialElementCount() {
INITIAL_ELEMENTS_COUNT = new HashMap<>();
INITIAL_ELEMENTS_COUNT.put(new Fire(), 1);
INITIAL_ELEMENTS_COUNT.put(new FireFigther(), 3);
INITIAL_ELEMENTS_COUNT.put(new Cloud(), 2);
INITIAL_ELEMENTS_COUNT.put(new MotorisedFirefigther(), 3);
INITIAL_ELEMENTS_COUNT.put(new Mountain(), 1);
INITIAL_ELEMENTS_COUNT.put(new Road(), 4);
INITIAL_ELEMENTS_COUNT.put(new Rockerie(), 5);
INITIAL_ELEMENTS_COUNT.put(new FireFigther(), 1);
INITIAL_ELEMENTS_COUNT.put(new Cloud(), 0);
INITIAL_ELEMENTS_COUNT.put(new MotorisedFirefigther(), 0);
INITIAL_ELEMENTS_COUNT.put(new Mountain(), 100);
INITIAL_ELEMENTS_COUNT.put(new Road(), 0);
INITIAL_ELEMENTS_COUNT.put(new Rockerie(), 0);
}
......@@ -59,9 +59,9 @@ public class SimulatorApplication extends javafx.application.Application {
URL location = SimulatorApplication.class.getResource(VIEW_RESOURCE_PATH);
loader.setLocation(location);
view = loader.load();
ControllerFireFigtherBord controller = loader.getController();
controller.initialize(SQUARE_WIDTH, SQUARE_HEIGHT, COLUMN_COUNT, ROW_COUNT,INITIAL_ELEMENTS_COUNT
);
//ControllerFireFigtherBord controller = loader.getController();
//controller.initialize(SQUARE_WIDTH, SQUARE_HEIGHT, COLUMN_COUNT, ROW_COUNT,INITIAL_ELEMENTS_COUNT
// );
}
private void showScene() {
......
package model.Element;
import util.Position;
import view.ViewElement;
import java.util.List;
import java.util.Map;
import static util.Tools.*;
public class Doctor implements ModelElement {
@Override
public void update(Position position, Map<Position, List<ModelElement>> board, int step, int columnCount, int rowCount) {
if(!extinguishneighbor(position,board,new Virus(),rowCount,columnCount)) {
Position newPositionStep = neighborClosestTo(position,board,rowCount,columnCount,new Virus(),List.of());
removeElement(position, board, new Doctor());
addElement(newPositionStep, board, new Doctor());
extinguishneighbor(newPositionStep,board,new Virus(),rowCount,columnCount);
}
}
@Override
public ViewElement getViewElement() {
return ViewElement.Doctor;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Doctor;
}
}
......@@ -11,13 +11,11 @@ import static util.Tools.*;
public class FireFigther implements ModelElement{
@Override
public void update(Position position, Map<Position, List<ModelElement>> board, int step, int columnCount, int rowCount) {
if(!extinguishneighbor(position,board,columnCount,rowCount)) {
Position newPositionStep = neighborClosestTo(position,board,rowCount,columnCount,new Fire(),List.of(new Mountain()));
if(!extinguishneighbor(position,board,new Fire(),rowCount,columnCount)) {
Position newPositionStep = neighborClosestTo(position,board,rowCount,columnCount,new Fire(),List.of(new Mountain(),new MotorisedFirefigther() ));
removeElement(position, board, new FireFigther());
addElement(newPositionStep, board, new FireFigther());
extinguishneighbor(newPositionStep,board,columnCount,rowCount);
extinguishneighbor(newPositionStep,board,new Fire(),rowCount,columnCount);
}
}
......
package model.Element;
import util.Position;
import view.ViewElement;
import java.util.List;
import java.util.Map;
import java.util.Random;
import static util.Tools.*;
public class Humain implements ModelElement{
@Override
public void update(Position position, Map<Position, List<ModelElement>> board, int step, int columnCount, int rowCount) {
List<Position> neighbors = neighbors(position, rowCount, columnCount);
if (!neighbors.isEmpty()) {
Random nextCloud = new Random();
Position randomNeighbor = neighbors.get(nextCloud.nextInt(neighbors.size()));
addElement(randomNeighbor, board, new Humain());
}
removeElement(position, board, new Humain());
}
@Override
public ViewElement getViewElement() {
return ViewElement.Humain;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Humain;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment