diff options
Diffstat (limited to 'src/main/java/space/m0e/quga/oop/lab56maven/entities')
8 files changed, 720 insertions, 0 deletions
diff --git a/src/main/java/space/m0e/quga/oop/lab56maven/entities/common/Ability.java b/src/main/java/space/m0e/quga/oop/lab56maven/entities/common/Ability.java new file mode 100644 index 0000000..9fc2e68 --- /dev/null +++ b/src/main/java/space/m0e/quga/oop/lab56maven/entities/common/Ability.java @@ -0,0 +1,5 @@ +package space.m0e.quga.oop.lab56maven.entities.common; + +public enum Ability { + WOODCUTTER, MASONIST +} diff --git a/src/main/java/space/m0e/quga/oop/lab56maven/entities/common/Coordinates.java b/src/main/java/space/m0e/quga/oop/lab56maven/entities/common/Coordinates.java new file mode 100644 index 0000000..a68f178 --- /dev/null +++ b/src/main/java/space/m0e/quga/oop/lab56maven/entities/common/Coordinates.java @@ -0,0 +1,33 @@ +package space.m0e.quga.oop.lab56maven.entities.common; + + +import space.m0e.quga.oop.lab56maven.entities.micro.Immigrant; + +public class Coordinates { + private double x; + private double y; + public Coordinates(double x, double y) { + this.x = x; + this.y = y; + } + + public double getX() { + return x; + } + + public void setX(double x) { + this.x = x; + } + + public double getY() { + return y; + } + + public void setY(double y) { + this.y = y; + } + + public boolean isThere(Immigrant immigrant) { + return (int) immigrant.getX() == (int) this.x && (int) immigrant.getY() == (int) this.y; + } +} diff --git a/src/main/java/space/m0e/quga/oop/lab56maven/entities/macro/Fortress.java b/src/main/java/space/m0e/quga/oop/lab56maven/entities/macro/Fortress.java new file mode 100644 index 0000000..36911f7 --- /dev/null +++ b/src/main/java/space/m0e/quga/oop/lab56maven/entities/macro/Fortress.java @@ -0,0 +1,129 @@ +package space.m0e.quga.oop.lab56maven.entities.macro; + +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.layout.*; +import javafx.scene.paint.Color; +import space.m0e.quga.oop.lab56maven.Main; +import space.m0e.quga.oop.lab56maven.entities.micro.Dwarf; +import space.m0e.quga.oop.lab56maven.entities.micro.Immigrant; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; + +public class Fortress { + private Image spriteImage = new Image(Objects.requireNonNull(Fortress.class.getResourceAsStream("fortress.jpeg")));; + private GridPane insideGroup = new GridPane(10, 10); + private Label nameLabel = new Label(); + private Label countLabel = new Label(); + + ArrayList<Workstation> workstations = new ArrayList<>(); + ArrayList<ThroneRoom> throneRooms = new ArrayList<>(); + + ArrayList<Dwarf> dwarves = new ArrayList<>(); + + private String name; + private double x; + private double y; + private VBox vBox = new VBox(); + + private GridPane dwarvesContainer = new GridPane(10, 10); + + public Fortress(String name, double x, double y, ArrayList<Workstation> workstations, ArrayList<ThroneRoom> throneRooms) { + this.x = x; + this.y = y; + + nameLabel.setText(name); + countLabel.setText("0"); + + nameLabel.setStyle("-fx-text-fill: red; -fx-font-size: 16px;"); + + RowConstraints insideRow = new RowConstraints(); + insideRow.setPrefHeight(200); + ColumnConstraints insideColumn = new ColumnConstraints(); + insideColumn.setPrefWidth(200); + for (int i = 0; i < 3; i++) { + insideGroup.getRowConstraints().add(insideRow); + insideGroup.getColumnConstraints().add(insideColumn); + } + + insideGroup.setBackground(new Background(new BackgroundImage(spriteImage, BackgroundRepeat.REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, BackgroundSize.DEFAULT))); + this.workstations = workstations; + this.throneRooms = throneRooms; + int col = 0; + int row = 0; + for (Workstation w : this.workstations) { + if (col > 3) { + col = 0; + row++; + } + insideGroup.add(w.getGroup(), col, row); + col++; + } + + for (ThroneRoom t : this.throneRooms) { + if (col > 3) { + col = 0; + row++; + } + insideGroup.add(t.getGroup(), col, row); + col++; + } + + insideGroup.add(dwarvesContainer, 2, 2); + + this.dwarvesContainer.setBorder(new Border(new BorderStroke(Color.RED, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(3)))); +// dwarvesContainer.setMinSize(100 * 3, 100 * 3); + + vBox.setLayoutX(x); + vBox.setLayoutY(y); + vBox.getChildren().addAll(nameLabel, insideGroup, countLabel); + + this.vBox.setBorder(new Border(new BorderStroke(Color.RED, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(3)))); + Main.root.getChildren().add(vBox); + }; + + public void add(Dwarf dwarf) { + dwarves.add(dwarf); + dwarvesContainer.add(dwarf.getGroup(), dwarves.size() % 3, dwarves.size() / 3); + } + + public void process() { + ArrayList<Immigrant> migration = (ArrayList<Immigrant>) Main.immigrants.stream().filter(immigrant -> immigrant.getClass().equals(Immigrant.class) && immigrant.getCoordinatesToFortress(this).isThere(immigrant)).collect(Collectors.toList()); + migration.forEach(immigrant -> { + Dwarf dwarf = new Dwarf(immigrant, this); + Main.immigrants.add(dwarf); + this.dwarves.add(dwarf); + Main.root.getChildren().remove(immigrant.getGroup()); + }); + Main.immigrants.removeAll(migration); + + countLabel.setText(String.valueOf(dwarves.size())); + + workstations.forEach(Workstation::process); + throneRooms.forEach(ThroneRoom::process); + } + + public double getX() { + return x; + } + + public double getY() { + return y; + } + + public ArrayList<Workstation> getWorkstations() { + return workstations; + } + + public VBox getGroup() { + return vBox; + } + + public ArrayList<Dwarf> getDwarves() { + return dwarves; + } + +} diff --git a/src/main/java/space/m0e/quga/oop/lab56maven/entities/macro/ThroneRoom.java b/src/main/java/space/m0e/quga/oop/lab56maven/entities/macro/ThroneRoom.java new file mode 100644 index 0000000..7a51cb5 --- /dev/null +++ b/src/main/java/space/m0e/quga/oop/lab56maven/entities/macro/ThroneRoom.java @@ -0,0 +1,52 @@ +package space.m0e.quga.oop.lab56maven.entities.macro; + +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.VBox; +import space.m0e.quga.oop.lab56maven.Main; +import space.m0e.quga.oop.lab56maven.entities.micro.Dwarf; +import space.m0e.quga.oop.lab56maven.entities.micro.Immigrant; +import space.m0e.quga.oop.lab56maven.entities.micro.Nobel; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; + +public class ThroneRoom { + private Image spriteImage = new Image(Objects.requireNonNull(ThroneRoom.class.getResourceAsStream("throne_room.jpg")));; + private ImageView sprite = new ImageView(spriteImage); + private Label nameLabel = new Label(); + private Label countLabel = new Label(); + + private ArrayList<Nobel> nobels = new ArrayList<>(); + String name; + + private VBox vBox = new VBox(); + + public ThroneRoom(String name) { + this.name = name; + + sprite.setFitHeight(150); + sprite.setFitWidth(150); + nameLabel.setText(name); + + nameLabel.setStyle("-fx-text-fill: white; -fx-font-size: 16px; -fx-background-color: grey"); + countLabel.setStyle("-fx-text-fill: white; -fx-font-size: 16px; -fx-background-color: grey"); + + vBox.getChildren().addAll(nameLabel, sprite, countLabel); + Main.root.getChildren().add(vBox); + }; + + public void process() { + countLabel.setText(String.valueOf(nobels.size())); + } + + public ArrayList<Nobel> getNobels() { + return nobels; + } + + public VBox getGroup() { + return vBox; + } +} diff --git a/src/main/java/space/m0e/quga/oop/lab56maven/entities/macro/Workstation.java b/src/main/java/space/m0e/quga/oop/lab56maven/entities/macro/Workstation.java new file mode 100644 index 0000000..fe80a2b --- /dev/null +++ b/src/main/java/space/m0e/quga/oop/lab56maven/entities/macro/Workstation.java @@ -0,0 +1,57 @@ +package space.m0e.quga.oop.lab56maven.entities.macro; + +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.VBox; +import javafx.scene.text.Font; +import space.m0e.quga.oop.lab56maven.Main; +import space.m0e.quga.oop.lab56maven.entities.micro.Dwarf; +import space.m0e.quga.oop.lab56maven.entities.micro.Immigrant; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; + +public class Workstation { + private Image spriteImage = new Image(Objects.requireNonNull(Workstation.class.getResourceAsStream("workstation.png")));; + private ImageView sprite = new ImageView(spriteImage); + private Label nameLabel = new Label(); + private Label countLabel = new Label(); + + private ArrayList<Dwarf> dwarves = new ArrayList<>(); + private String name; + + private VBox vBox = new VBox(); + + public Workstation(String name) { + this.name = name; + + sprite.setFitHeight(150); + sprite.setFitWidth(150); + nameLabel.setText(name); + + nameLabel.setStyle("-fx-text-fill: white; -fx-font-size: 16px; -fx-background-color: grey"); + countLabel.setStyle("-fx-text-fill: white; -fx-font-size: 16px; -fx-background-color: grey"); + + vBox.getChildren().addAll(nameLabel, sprite, countLabel); + Main.root.getChildren().add(vBox); + }; + + public void process() { + Optional<Immigrant> entered = Main.immigrants.stream().filter(immigrant -> immigrant instanceof Dwarf && vBox.getBoundsInParent().contains(immigrant.getGroup().getBoundsInParent())).findFirst(); + entered.ifPresent(immigrant -> { + dwarves.add((Dwarf) immigrant); + }); + countLabel.setText(String.valueOf(dwarves.size())); + } + + public ArrayList<Dwarf> getDwarves() { + return dwarves; + } + + public VBox getGroup() { + return vBox; + } +} diff --git a/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Dwarf.java b/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Dwarf.java new file mode 100644 index 0000000..d00f24f --- /dev/null +++ b/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Dwarf.java @@ -0,0 +1,92 @@ +package space.m0e.quga.oop.lab56maven.entities.micro; + +import javafx.scene.image.Image; +import space.m0e.quga.oop.lab56maven.Main; +import space.m0e.quga.oop.lab56maven.entities.common.Ability; +import space.m0e.quga.oop.lab56maven.entities.common.Coordinates; +import space.m0e.quga.oop.lab56maven.entities.macro.Fortress; +import space.m0e.quga.oop.lab56maven.entities.macro.Workstation; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Optional; +import java.util.Random; +import java.util.stream.Collectors; + +public class Dwarf extends Immigrant { + private Fortress fortress = null; + private Workstation workstation = null; + public Image spriteImage = new Image(Objects.requireNonNull(Immigrant.class.getResourceAsStream("dwarf.png")));; + public Dwarf(String firstName, String lastName, int age, double x, double y, Ability ability) { + super(firstName, lastName, age, x, y, ability); + getSprite().setImage(spriteImage); + } + + public Dwarf() { + this("Edzul", "Èrithbesmar", 35, 0, 0, Ability.values()[new Random().nextInt(Ability.values().length)]); + } + + public Dwarf(Immigrant immigrant, Fortress fortress) { + this(immigrant.getFirstName(), immigrant.getLastName(), immigrant.getAge(), immigrant.getX(), immigrant.getY(), immigrant.getAbility()); + this.setItems((ArrayList<String>) immigrant.getItems().clone()); + this.setHp(this.getHp()); + this.setMaxHp(this.getMaxHp()); + this.fortress = fortress; + } + + public Workstation findNearestWorkstation() { + ArrayList<Workstation> searchWorkstations = (ArrayList<Workstation>) fortress.getWorkstations().stream().filter(w -> w.getDwarves().isEmpty()).collect(Collectors.toList()); + searchWorkstations.sort((o1, o2) -> (int) ((Math.abs(o1.getGroup().getLayoutX() - this.getX()) + Math.abs(o1.getGroup().getLayoutY() - this.getY())) - ((Math.abs(o2.getGroup().getLayoutX() - this.getX()) + Math.abs(o2.getGroup().getLayoutY() - this.getY()))))); + if (searchWorkstations.isEmpty()) { + return null; + } else { + return searchWorkstations.get(0); + } + } + + public Coordinates getCoordinatesToWorkstation(Workstation workstation) { + double workstationX = workstation.getGroup().getLayoutX() + workstation.getGroup().getBoundsInParent().getWidth() - this.getGroup().getBoundsInParent().getWidth(); + double workstationY = workstation.getGroup().getLayoutX() + workstation.getGroup().getBoundsInParent().getHeight() - this.getGroup().getBoundsInParent().getHeight(); + return new Coordinates(workstationX, workstationY); + } + + @Override + public void moveAI() { + if (fortress == null) { + fortress = findNearestFortress(); + fortress.getDwarves().add(this); + } + if (!fortress.getGroup().getBoundsInParent().contains(this.getGroup().getBoundsInParent())) { + super.moveAI(); + } else { + if (workstation == null) { + workstation = findNearestWorkstation(); + if (workstation == null) { + super.moveAI(); + } else { + Coordinates workstationToMove = this.getCoordinatesToWorkstation(workstation); + if (!workstationToMove.isThere(this)) { + double workstationX = workstationToMove.getX(); + double workstationY = workstationToMove.getY(); + + if (workstationX > this.getX()) { + this.setX(this.getX() + 1); + } + + if (workstationX < this.getX()) { + this.setX(this.getX() - 1); + } + + if (workstationY > this.getY()) { + this.setY(this.getY() + 1); + } + + if (workstationY < this.getY()) { + this.setY(this.getY() - 1); + } + } + } + } + } + } +} diff --git a/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Immigrant.java b/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Immigrant.java new file mode 100644 index 0000000..f91d0c2 --- /dev/null +++ b/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Immigrant.java @@ -0,0 +1,333 @@ +package space.m0e.quga.oop.lab56maven.entities.micro; + +import javafx.geometry.Pos; +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.*; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import space.m0e.quga.oop.lab56maven.dialogs.ChangeDialog; +import space.m0e.quga.oop.lab56maven.Main; +import space.m0e.quga.oop.lab56maven.entities.common.Ability; +import space.m0e.quga.oop.lab56maven.entities.common.Coordinates; +import space.m0e.quga.oop.lab56maven.entities.macro.Fortress; +import space.m0e.quga.oop.lab56maven.threads.ImmigrantThread; + +import java.io.IOException; +import java.util.*; +import java.util.concurrent.ForkJoinTask; +import java.util.stream.Collectors; + +public class Immigrant implements Comparable<Immigrant>, Cloneable { + private String firstName; + private String lastName; + private int age; + private double x; + private double y; + private Ability ability; + + private ArrayList<String> items = new ArrayList<>(); + private static final String[] availableItems = new String[]{"axe", "pickaxe", "shovel", "piece of coal", "wood log"}; + + private double hp; + private double maxHp; + private static final double hpCap; + + private boolean isActive = false; + + private final VBox vBox = new VBox(); + private final Label label; + + private final ImageView sprite; + private final Rectangle hpBar; + private static final Image spriteImage = new Image(Objects.requireNonNull(Immigrant.class.getResourceAsStream("immigrant.png"))); + + private ImmigrantThread thread = new ImmigrantThread(this); + + public Immigrant(String firstName, String lastName, int age, double x, double y, Ability ability) { + this.firstName = firstName; + this.lastName = lastName; + this.age = age; + this.x = x; + this.y = y; + this.ability = ability; + + this.label = new Label(firstName + " " + lastName); + this.sprite = new ImageView(spriteImage); + this.hpBar = new Rectangle(50, 10); + this.hpBar.widthProperty().multiply(this.hp/this.maxHp); + this.hpBar.setFill(Color.LIME); + this.vBox.setSpacing(5); + this.vBox.setLayoutX(this.x); + this.vBox.setLayoutY(this.y); + this.vBox.getChildren().addAll(label, sprite, hpBar); + this.vBox.setAlignment(Pos.CENTER); + this.vBox.setOnMouseClicked(event -> { + switch (event.getButton()) { + case PRIMARY -> { + this.setActive(!this.isActive); + } + case SECONDARY -> { + try { + ChangeDialog.display(this); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + }); + this.thread = new ImmigrantThread(this); + Main.root.getChildren().add(this.getGroup()); + } + + public Immigrant() { + this("Edzul", "Èrithbesmar", 35, 0, 0, Ability.values()[new Random().nextInt(Ability.values().length)]); + } + + public boolean isActive() { + return isActive; + } + + public VBox getGroup() { + return vBox; + } + + public ImageView getSprite() { + return sprite; + } + + public Ability getAbility() { + return ability; + } + + public void setAbility(Ability ability) { + this.ability = ability; + } + + public ArrayList<String> getItems() { + return items; + } + + public void setItems(ArrayList<String> items) { + this.items = items; + } + + static { + hpCap = 100 + new Random().nextInt(50); + } + + { + maxHp = 50 + new Random().nextInt(100); + hp = maxHp; + int itemCount = new Random().nextInt(1, availableItems.length); + ArrayList<String> itemPick = new ArrayList<String>(List.of(availableItems)); + Collections.shuffle(itemPick); + items = (ArrayList<String>) itemPick.stream().limit(itemCount).collect(Collectors.toList()); + } + + public String getFullName() { + return this.firstName + " " + this.lastName; + } + + public String getFirstName() { + return this.firstName; + } + + public String getLastName() { + return this.lastName; + } + + public int getAge() { + return this.age; + } + + public double getX() { + return this.x; + } + + public double getY() { + return this.y; + } + + public double getHp() { + return this.hp; + } + + public double getMaxHp() { + return this.maxHp; + } + + public double getHpCap() { + return Immigrant.hpCap; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + this.label.setText(firstName + " " + this.lastName); + } + + public void setLastName(String lastName) { + this.lastName = lastName; + this.label.setText(firstName + " " + this.lastName); + } + + public void setAge(int age) { + this.age = age; + } + + public void setX(double x) { + this.x = x; + this.vBox.setLayoutX(this.x); + } + + public void setY(double y) { + this.y = y; + this.vBox.setLayoutY(this.y); + } + + public void setHp(double hp) { + this.hp = hp; + this.hpBar.widthProperty().multiply(this.hp / this.maxHp); + } + + public void setMaxHp(double maxHp) { + this.maxHp = maxHp; + if (this.maxHp > Immigrant.hpCap) { + this.maxHp = Immigrant.hpCap; + } + this.hpBar.widthProperty().multiply(this.hp / this.maxHp); + } + + @Override + public String toString() { + return String.format("%s{Name=%s, Age=%d, Ability=%s, HP: %f/%f, Items: [%s]}", this.getClass().getSimpleName(), this.getFullName(), this.age, this.ability, this.hp, this.maxHp, String.join(", ", this.items)); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Immigrant immigrant = (Immigrant) o; + + return Objects.equals(this.firstName, immigrant.firstName) && Objects.equals(this.lastName, immigrant.lastName); + } + + + public void setActive(boolean active) { + this.isActive = active; + if (this.isActive) { + this.vBox.setBorder(new Border(new BorderStroke(Color.RED, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, new BorderWidths(3)))); + } else { + this.vBox.setBorder(null); + } + Main.processImmigrants(); + } + + + public void print() { + System.out.println(this); + } + + public void grow() { + this.age++; + if (age > 24) { + this.maxHp--; + if (this.hp > this.maxHp) { + this.hp = this.maxHp; + } + } else { + this.maxHp++; + this.hp++; + } + } + + public void hurt(double deltaHp) { + this.hp -= deltaHp; + if (this.hp < 0) { + this.hp = 0; + } + } + + public void heal(double deltaHp) { + this.hp += deltaHp; + if (this.hp > this.maxHp) { + this.hp = this.maxHp; + } + } + + public void attack(Immigrant immigrant) { + double deltaHp = new Random().nextDouble(maxHp); + immigrant.hurt(deltaHp); + + System.out.printf(""" + %s attacked %s (%f HP) + %s HP: %f/%f + """, + this.getFullName(), immigrant.getFullName(), deltaHp, + immigrant.getFullName(), immigrant.getHp(), immigrant.getMaxHp()); + } + + public Coordinates getCoordinatesToFortress(Fortress fortress) { + int dwarvesCount = fortress.getDwarves().size(); + + double fortressX = fortress.getX() + fortress.getGroup().getBoundsInParent().getWidth() / 2 - this.getGroup().getWidth() / 2; + double fortressY = fortress.getY() + fortress.getGroup().getBoundsInParent().getHeight() / 2 - this.getGroup().getHeight() / 2; + return new Coordinates(fortressX, fortressY); + } + + public Fortress findNearestFortress() { + ArrayList<Fortress> searchFortresses = (ArrayList<Fortress>) Main.fortresses.clone(); + searchFortresses.sort((o1, o2) -> { + return (int) ((Math.abs(o1.getX() - this.x) + Math.abs(o1.getY() - this.y)) - (Math.abs(o2.getX() - this.x) + Math.abs(o2.getY() - this.y))); + }); + return searchFortresses.stream().filter(f -> f.getDwarves().size() < 9).findFirst().orElse(null); + } + + public void moveAI() { + Fortress searchFortress = findNearestFortress(); + Coordinates fortressToMove = this.getCoordinatesToFortress(searchFortress); + } + + public void move(Coordinates coordinates) { + if (!coordinates.isThere(this)) { + double pointX = coordinates.getX(); + double pointY = coordinates.getY(); + + if (pointX > this.getX()) { + this.setX(this.getX() + 1); + } + + if (pointX < this.getX()) { + this.setX(this.getX() - 1); + } + + if (pointY > this.getY()) { + this.setY(this.getY() + 1); + } + + if (pointY < this.getY()) { + this.setY(this.getY() - 1); + } + } + } + + @Override + public int compareTo(Immigrant o) { + return (int) (this.hp - o.hp); + } + + @Override + public Immigrant clone() throws CloneNotSupportedException { + Immigrant immigrant = (Immigrant) super.clone(); + immigrant.setItems((ArrayList<String>) this.items.clone()); + return immigrant; + } + + public ImmigrantThread getThread() { + return thread; + } +} diff --git a/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Nobel.java b/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Nobel.java new file mode 100644 index 0000000..ed9ba7a --- /dev/null +++ b/src/main/java/space/m0e/quga/oop/lab56maven/entities/micro/Nobel.java @@ -0,0 +1,19 @@ +package space.m0e.quga.oop.lab56maven.entities.micro; + +import javafx.scene.image.Image; +import space.m0e.quga.oop.lab56maven.entities.common.Ability; + +import java.util.Objects; +import java.util.Random; + +public class Nobel extends Immigrant { + public Image spriteImage = new Image(Objects.requireNonNull(Nobel.class.getResourceAsStream("nobel.png")));; + public Nobel(String firstName, String lastName, int age, double x, double y, Ability ability) { + super(firstName, lastName, age, x, y, ability); + getSprite().setImage(spriteImage); + } + + public Nobel() { + this("Edzul", "Èrithbesmar", 35, 0, 0, Ability.values()[new Random().nextInt(Ability.values().length)]); + } +} |
