feat: JavaDoc

This commit is contained in:
2025-05-30 16:21:10 +02:00
parent 2cbc692470
commit b5c6523b45
26 changed files with 379 additions and 61 deletions

View File

@@ -123,7 +123,7 @@ public class Game {
} }
System.out.println(); System.out.println();
player.setCoins(300); player.setCoins(1000);
strings.print("coins", player.getCoins()); strings.print("coins", player.getCoins());
System.out.println(); System.out.println();
@@ -197,14 +197,17 @@ public class Game {
} }
/** /**
* Function that picks an item for harvesting and puts teh produce in inventory * Function that picks an item for harvesting and puts the produce in inventory
* *
* @param item Item that is being harvested * @param item Item that is being harvested
*/ */
public void harvest(Item item) { public void harvest(Item item) {
Item item2 = switch (item) { Item item2 = switch (item) {
case WHEAT_FARMLAND -> Item.WHEAT;
} case HOPS_FARMLAND -> Item.HOPS;
case VINEYARD -> Item.GRAPEVINE;
default -> throw new IllegalArgumentException("Error: You can't harvest " + item);
};
if (waterType.getFarmlandCount() > buildings.stream().filter(item1 -> item1 == item2).count()) { if (waterType.getFarmlandCount() > buildings.stream().filter(item1 -> item1 == item2).count()) {
System.out.println("You can't harvest"); System.out.println("You can't harvest");
@@ -214,42 +217,6 @@ public class Game {
buildings.remove(item2); buildings.remove(item2);
player.getInventory().add(item2); player.getInventory().add(item2);
} }
switch (item) {
case WHEAT_FARMLAND -> {
if (waterType.getFarmlandCount() > buildings.stream().filter(item1 -> item1 == Item.WHEAT).count()) {
System.out.println("You can't harvest");
return;
}
for (int i = 0; i < waterType.getFarmlandCount() ; i++) {
buildings.remove(Item.WHEAT);
player.getInventory().add(Item.WHEAT);
}
}
case HOPS_FARMLAND -> {
if (waterType.getFarmlandCount() > buildings.stream().filter(item1 -> item1 == Item.HOPS).count()) {
System.out.println("You can't harvest");
return;
}
for (int i = 0; i < waterType.getFarmlandCount() ; i++) {
buildings.remove(Item.HOPS);
player.getInventory().add(Item.HOPS);
}
}
case VINEYARD -> {
if (waterType.getFarmlandCount() > buildings.stream().filter(item1 -> item1 == Item.GRAPEVINE).count()) {
System.out.println("You can't harvest");
return;
}
for (int i = 0; i < waterType.getFarmlandCount() ; i++) {
buildings.remove(Item.GRAPEVINE);
player.getInventory().add(Item.GRAPEVINE);
}
}
}
} }
/** /**

View File

@@ -1,6 +1,15 @@
package cz.jull.exceptions; package cz.jull.exceptions;
/**
* Exception thrown when an item is not available for an action (e.g., purchase).
*/
public class ItemNotAvailableException extends RuntimeException { public class ItemNotAvailableException extends RuntimeException {
/**
* Constructs a new exception with the specified detail message.
*
* @param message the detail message explaining the reason for the exception
*/
public ItemNotAvailableException(String message) { public ItemNotAvailableException(String message) {
super(message); super(message);
} }

View File

@@ -0,0 +1,16 @@
package cz.jull.exceptions;
/**
* Exception thrown when a player does not have enough coins to perform an action.
*/
public class NotSufficientCoinsException extends RuntimeException {
/**
* Constructs a new exception with the specified detail message.
*
* @param message the detail message explaining the reason for the exception
*/
public NotSufficientCoinsException(String message) {
super(message);
}
}

View File

@@ -1,7 +0,0 @@
package cz.jull.exceptions;
public class NotSufficientsCoinsException extends RuntimeException {
public NotSufficientsCoinsException(String message) {
super(message);
}
}

View File

@@ -2,6 +2,17 @@ package cz.jull.items;
import cz.jull.Game; import cz.jull.Game;
/**
* Represents an item that can be built within the game.
* Implementing classes should define the logic that determines
* whether the item can currently be built, based on the game state.
*/
public interface Buildable { public interface Buildable {
/**
* Determines whether the item can be built
*
* @param game The game
* @return {@code true} if the item can be built; {@code false} otherwise
*/
boolean canBuild(Game game); boolean canBuild(Game game);
} }

View File

@@ -3,8 +3,22 @@ package cz.jull.items.actions;
import cz.jull.Game; import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
/**
* Represents an abstract action that can be performed on an item within the game
*/
public abstract class Action { public abstract class Action {
/**
* Returns the name or description of the action
*
* @return a string representing the action
*/
public abstract String toString(); public abstract String toString();
/**
* Executes the action on the given item
*
* @param game The game
* @param item The item on which the action is performed
*/
public abstract void execute(Game game, Item item); public abstract void execute(Game game, Item item);
} }

View File

@@ -3,12 +3,26 @@ package cz.jull.items.actions;
import cz.jull.Game; import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
/**
* Represents a build action that can be performed on an item.
*/
public class BuildAction extends Action { public class BuildAction extends Action {
/**
* Returns the name of the action.
*
* @return the string "Build"
*/
@Override @Override
public String toString() { public String toString() {
return "Build"; return "Build";
} }
/**
* Executes the build action on the given item
*
* @param game The game
* @param item The item to be built
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.build(item); game.build(item);

View File

@@ -4,12 +4,30 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
/**
* Represents the action of cutting trees using an axe.
*/
public class AxeCutTreesAction extends Action { public class AxeCutTreesAction extends Action {
/**
* Returns the name of the action.
*
* @return the string "Cut trees"
*/
@Override @Override
public String toString() { public String toString() {
return "Cut trees"; return "Cut trees";
} }
/**
* Executes the tree-cutting action.
* <p>
* This method calls {@link Game#cutTrees()} to perform the action.
* The provided {@code item} parameter is not used in this implementation.
*
* @param game The game
* @param item The item related to the action (not used here)
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.cutTrees(); game.cutTrees();

View File

@@ -4,12 +4,27 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
/**
* Represents an action for producing bread in the bakery
*/
public class BakeryProduceAction extends Action { public class BakeryProduceAction extends Action {
/**
* Returns the name of the action.
*
* @return the string "Produce bread"
*/
@Override @Override
public String toString() { public String toString() {
return "Produce bread"; return "Produce bread";
} }
/**
* Executes the bread production action on the given item
*
* @param game The game
* @param item The item on which the action is performed
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.produce(item); game.produce(item);

View File

@@ -4,12 +4,27 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
/**
* Represents an action for producing cheese in the cheese factory
*/
public class CheeseFactoryProduceAction extends Action { public class CheeseFactoryProduceAction extends Action {
/**
* Returns the name of the action.
*
* @return the string "Produce cheese"
*/
@Override @Override
public String toString() { public String toString() {
return "Produce cheese"; return "Produce cheese";
} }
/**
* Executes the cheese production action on the given item
*
* @param game The game
* @param item The item on which the action is performed
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.produce(item); game.produce(item);

View File

@@ -4,12 +4,27 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
/**
* Represents an action for producing coal in the coal factory
*/
public class CoalFactoryProduceAction extends Action { public class CoalFactoryProduceAction extends Action {
/**
* Returns the name of the action
*
* @return the string "Produce coal"
*/
@Override @Override
public String toString() { public String toString() {
return "Produce coal"; return "Produce coal";
} }
/**
* Executes the coal production action on the given item
*
* @param game The game
* @param item The item on which the action is performed
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.produce(item); game.produce(item);

View File

@@ -4,12 +4,30 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
/**
* Represents the action of milking a cow
*/
public class CowMilkAction extends Action { public class CowMilkAction extends Action {
/**
* Returns the name of the action
*
* @return the string "Get milk"
*/
@Override @Override
public String toString() { public String toString() {
return "Get milk"; return "Get milk";
} }
/**
* Executes the milking action
* <p>
* This method calls {@link Game#milkCow()} to perform the milking operation.
* The provided {@code item} parameter is not used in this implementation.
*
* @param game The game
* @param item The item related to the action (not used here)
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.milkCow(); game.milkCow();

View File

@@ -4,12 +4,27 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
/**
* Represents the action of harvesting hops from a hops farmland
*/
public class HopsFarmlandHarvestAction extends Action { public class HopsFarmlandHarvestAction extends Action {
/**
* Returns the name of the action
*
* @return the string "Harvest hops"
*/
@Override @Override
public String toString() { public String toString() {
return "Harvest hops"; return "Harvest hops";
} }
/**
* Executes the hops harvest action on the given item
*
* @param game The game
* @param item The item on which the action is performed
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.harvest(Item.HOPS_FARMLAND); game.harvest(Item.HOPS_FARMLAND);

View File

@@ -4,12 +4,27 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
/**
* Represents the action of planting hops seeds on a hops farmland
*/
public class HopsFarmlandPlantAction extends Action { public class HopsFarmlandPlantAction extends Action {
/**
* Returns the name of the action
*
* @return the string "Plant hops seeds"
*/
@Override @Override
public String toString() { public String toString() {
return "Plant hops seeds"; return "Plant hops seeds";
} }
/**
* Executes the hops seeds plant action on the given item
*
* @param game The game
* @param item The item on which the action is performed
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.build(Item.HOPS_SEEDS); game.build(Item.HOPS_SEEDS);

View File

@@ -4,12 +4,27 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
/**
* Represents an action for producing beer in the pub
*/
public class PubProduceAction extends Action { public class PubProduceAction extends Action {
/**
* Returns the name of the action.
*
* @return the string "Produce beer"
*/
@Override @Override
public String toString() { public String toString() {
return "Produce beer"; return "Produce beer";
} }
/**
* Executes the beer production action on the given item
*
* @param game The game
* @param item The item on which the action is performed
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.produce(item); game.produce(item);

View File

@@ -4,12 +4,27 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
/**
* Represents the action of harvesting grapevines from a vineyard
*/
public class VineyardHarvestAction extends Action { public class VineyardHarvestAction extends Action {
/**
* Returns the name of the action
*
* @return the string "Harvest grapevines"
*/
@Override @Override
public String toString() { public String toString() {
return "Harverst grapevines"; return "Harvest grapevines";
} }
/**
* Executes the grapevine harvest action on the given item
*
* @param game The game
* @param item The item on which the action is performed
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.harvest(Item.VINEYARD); game.harvest(Item.VINEYARD);

View File

@@ -4,12 +4,27 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
/**
* Represents the action of planting grapevines on a vineyard
*/
public class VineyardPlantAction extends Action { public class VineyardPlantAction extends Action {
/**
* Returns the name of the action
*
* @return the string "Plant grapevine seeds"
*/
@Override @Override
public String toString() { public String toString() {
return "Plant grapevine seeds"; return "Plant grapevine seeds";
} }
/**
* Executes the grapevine plant action on the given item
*
* @param game The game
* @param item The item on which the action is performed
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.build(Item.GRAPEVINE_SEEDS); game.build(Item.GRAPEVINE_SEEDS);

View File

@@ -4,12 +4,27 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
/**
* Represents the action of harvesting wheat from a wheat farmland
*/
public class WheatFarmlandHarvestAction extends Action { public class WheatFarmlandHarvestAction extends Action {
/**
* Returns the name of the action
*
* @return the string "Harvest wheat"
*/
@Override @Override
public String toString() { public String toString() {
return "Harvest wheats"; return "Harvest wheat";
} }
/**
* Executes the wheat harvest action on the given item
*
* @param game The game
* @param item The item on which the action is performed
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.harvest(Item.WHEAT_FARMLAND); game.harvest(Item.WHEAT_FARMLAND);

View File

@@ -4,12 +4,27 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
/**
* Represents the action of planting wheat seeds on a wheat farmland
*/
public class WheatFarmlandPlantAction extends Action { public class WheatFarmlandPlantAction extends Action {
/**
* Returns the name of the action
*
* @return the string "Plant wheat seeds"
*/
@Override @Override
public String toString() { public String toString() {
return "Plant wheat seeds"; return "Plant wheat seeds";
} }
/**
* Executes the wheat seeds plant action on the given item
*
* @param game The game
* @param item The item on which the action is performed
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.build(Item.WHEAT_SEEDS); game.build(Item.WHEAT_SEEDS);

View File

@@ -4,12 +4,27 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
/**
* Represents an action for producing wine in a winery
*/
public class WineryProduceAction extends Action { public class WineryProduceAction extends Action {
/**
* Returns the name of the action
*
* @return the string "Produce wine"
*/
@Override @Override
public String toString() { public String toString() {
return "Produce wine"; return "Produce wine";
} }
/**
* Executes the wine production action on the given item
*
* @param game The game
* @param item The item on which the action is performed
*/
@Override @Override
public void execute(Game game, Item item) { public void execute(Game game, Item item) {
game.produce(item); game.produce(item);

View File

@@ -3,7 +3,7 @@ package cz.jull.market;
import cz.jull.Game; import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.exceptions.ItemNotAvailableException; import cz.jull.exceptions.ItemNotAvailableException;
import cz.jull.exceptions.NotSufficientsCoinsException; import cz.jull.exceptions.NotSufficientCoinsException;
import cz.jull.stats.surroundings.PathType; import cz.jull.stats.surroundings.PathType;
import cz.jull.stats.surroundings.SoilType; import cz.jull.stats.surroundings.SoilType;
import lombok.Getter; import lombok.Getter;
@@ -11,13 +11,28 @@ import lombok.Getter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* Class that manages buying and selling logic
*/
@Getter @Getter
public class Market { public class Market {
/**
* The available items
*/
private final List<Item> availableItems = new ArrayList<>(List.of( private final List<Item> availableItems = new ArrayList<>(List.of(
Item.AXE, Item.AXE,
Item.VILLAGER_HOUSE, Item.CHURCH Item.VILLAGER_HOUSE, Item.CHURCH
)); ));
/**
* Sells an item from the player's inventory.
* <p>
* If the item is in the player's inventory, it is removed and its price is added to the player's coins.
* If the item is not in the inventory, a message is printed and no action is taken.
*
* @param game The game
* @param item Item that is being sold
*/
public void sellItem(Game game, Item item) { public void sellItem(Game game, Item item) {
if (!game.getPlayer().getInventory().contains(item)) { if (!game.getPlayer().getInventory().contains(item)) {
game.getStrings().print("cantSell"); game.getStrings().print("cantSell");
@@ -29,17 +44,28 @@ public class Market {
game.getStrings().print("marketSellMessage", item); game.getStrings().print("marketSellMessage", item);
} }
public void buyItem(Game game, Item item) throws ItemNotAvailableException, NotSufficientsCoinsException { /**
* Buys an item from the {@link #availableItems}
* <p>
* Function that takes item from the {@link #availableItems} and then adds it to player's inventory.
* If the item is a farmland or seed item, it is added multiple times based on the player's water type.
*
* @param game The game
* @param item Item that is being bought
* @throws ItemNotAvailableException If the item is not present in {@link #availableItems}
* @throws NotSufficientCoinsException If the player does not have enough coins to buy the item (or enough for multiple copies)
*/
public void buyItem(Game game, Item item) throws ItemNotAvailableException, NotSufficientCoinsException {
if (game.getPlayer().getCoins() < item.getPrice()) { if (game.getPlayer().getCoins() < item.getPrice()) {
throw new NotSufficientsCoinsException("Not enough coins"); throw new NotSufficientCoinsException("Not enough coins");
} }
if (availableItems.contains(item)) { if (availableItems.contains(item)) {
if (List.of(Item.WHEAT_SEEDS, Item.HOPS_SEEDS, Item.GRAPEVINE_SEEDS, Item.WHEAT_FARMLAND, Item.HOPS_FARMLAND, Item.VINEYARD).contains(item)) { if (List.of(Item.WHEAT_SEEDS, Item.HOPS_SEEDS, Item.GRAPEVINE_SEEDS, Item.WHEAT_FARMLAND, Item.HOPS_FARMLAND, Item.VINEYARD).contains(item)) {
if (game.getPlayer().getCoins() < (long) item.getPrice() * game.getWaterType().getFarmlandAndVineyardCount()) { if (game.getPlayer().getCoins() < (long) item.getPrice() * game.getWaterType().getFarmlandCount()) {
throw new NotSufficientsCoinsException("Not enough coins, you need " + game.getWaterType().getFarmlandAndVineyardCount() * item.getPrice() + " coins"); throw new NotSufficientCoinsException("Not enough coins, you need " + game.getWaterType().getFarmlandCount() * item.getPrice() + " coins");
} }
for (int i = 0; i < game.getWaterType().getFarmlandAndVineyardCount() ; i++) { for (int i = 0; i < game.getWaterType().getFarmlandCount() ; i++) {
game.getPlayer().getInventory().add(item); game.getPlayer().getInventory().add(item);
game.getPlayer().setCoins(game.getPlayer().getCoins() - item.getPrice()); game.getPlayer().setCoins(game.getPlayer().getCoins() - item.getPrice());
} }
@@ -57,6 +83,11 @@ public class Market {
} }
} }
/**
* Constructor that adds different items for different stats
*
* @param game The game
*/
public Market(Game game) { public Market(Game game) {
// Soil Type // Soil Type
if (game.getSoilType() == SoilType.STONY) { if (game.getSoilType() == SoilType.STONY) {

View File

@@ -6,21 +6,38 @@ import lombok.Setter;
import java.util.Random; import java.util.Random;
/**
* Enum that manages forest types for the game
*/
@AllArgsConstructor @AllArgsConstructor
public enum ForestType { public enum ForestType {
SMALL("Small", 25, 1), SMALL("Small", 25, 1),
MEDIUM("Medium",50, 3), MEDIUM("Medium",50, 3),
LARGE("Large", 100, 5); LARGE("Large", 100, 5);
/**
* Human-readable name
*/
private final String name; private final String name;
/**
* Size of the forest type
*/
@Getter @Getter
@Setter @Setter
private int size; private int size;
/**
* Axes needed for cutting trees
*/
@Getter @Getter
private final int axesNeeded; private final int axesNeeded;
/**
* Function that returns random path type
*
* @return random enum
*/
public static ForestType getRandom() { public static ForestType getRandom() {
Random random = new Random(); Random random = new Random();
ForestType[] types = values(); ForestType[] types = values();
@@ -28,6 +45,11 @@ public enum ForestType {
return types[random.nextInt(types.length)]; return types[random.nextInt(types.length)];
} }
/**
* Returns human-readable name
*
* @return Human-readable name
*/
@Override @Override
public String toString() { public String toString() {
return name; return name;

View File

@@ -2,17 +2,28 @@ package cz.jull.stats.surroundings;
import java.util.Random; import java.util.Random;
/**
* Enum that manages path types for the game
*/
public enum PathType { public enum PathType {
DEAD_END("Dead end"), DEAD_END("Dead end"),
SIDE_PATH("Side path"), SIDE_PATH("Side path"),
MAIN_PATH("Main path"),; MAIN_PATH("Main path"),;
/**
* Human-readable name
*/
private final String name; private final String name;
PathType(String name) { PathType(String name) {
this.name = name; this.name = name;
} }
/**
* Function that returns random path type
*
* @return random enum
*/
public static PathType getRandom() { public static PathType getRandom() {
Random random = new Random(); Random random = new Random();
PathType[] types = values(); PathType[] types = values();
@@ -20,6 +31,11 @@ public enum PathType {
return types[random.nextInt(types.length)]; return types[random.nextInt(types.length)];
} }
/**
* Returns human-readable name
*
* @return Human-readable name
*/
@Override @Override
public String toString() { public String toString() {
return name; return name;

View File

@@ -2,13 +2,28 @@ package cz.jull.stats.surroundings;
import java.util.Random; import java.util.Random;
/**
* Enum that manages soil types for the game
*/
public enum SoilType { public enum SoilType {
STONY("Stony"), STONY("Stony"),
LESS_FERTILE("Moderately fertile"), LESS_FERTILE("Moderately fertile"),
FERTILE("Fertile"),; FERTILE("Fertile"),;
/**
* Human-readable name
*/
private final String name; private final String name;
SoilType(String name) {
this.name = name;
}
/**
* Function that returns random soil type
*
* @return random enum
*/
public static SoilType getRandom() { public static SoilType getRandom() {
Random random = new Random(); Random random = new Random();
SoilType[] types = values(); SoilType[] types = values();
@@ -16,10 +31,11 @@ public enum SoilType {
return types[random.nextInt(types.length)]; return types[random.nextInt(types.length)];
} }
SoilType(String name) { /**
this.name = name; * Returns human-readable name
} *
* @return Human-readable name
*/
@Override @Override
public String toString() { public String toString() {
return name; return name;

View File

@@ -5,6 +5,9 @@ import lombok.Getter;
import java.util.Random; import java.util.Random;
/**
* Enum that manages water types for the game
*/
@AllArgsConstructor @AllArgsConstructor
public enum WaterType { public enum WaterType {
WELL("Well",5), WELL("Well",5),
@@ -19,6 +22,11 @@ public enum WaterType {
@Getter @Getter
private final int farmlandCount; private final int farmlandCount;
/**
* Function that returns random water type
*
* @return random enum
*/
public static WaterType getRandom() { public static WaterType getRandom() {
Random random = new Random(); Random random = new Random();
WaterType[] types = values(); WaterType[] types = values();

View File

@@ -4,7 +4,7 @@ import cz.jull.Game;
import cz.jull.items.Item; import cz.jull.items.Item;
import cz.jull.items.actions.Action; import cz.jull.items.actions.Action;
import cz.jull.exceptions.ItemNotAvailableException; import cz.jull.exceptions.ItemNotAvailableException;
import cz.jull.exceptions.NotSufficientsCoinsException; import cz.jull.exceptions.NotSufficientCoinsException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import java.io.IOException; import java.io.IOException;
@@ -95,7 +95,7 @@ public class Menu {
Item item = game.getMarket().getAvailableItems().get(itemIndex); Item item = game.getMarket().getAvailableItems().get(itemIndex);
try { try {
game.getMarket().buyItem(game, item); game.getMarket().buyItem(game, item);
} catch (NotSufficientsCoinsException | ItemNotAvailableException e) { } catch (NotSufficientCoinsException | ItemNotAvailableException e) {
System.out.println("\033[4;31mError: " + e.getMessage() + "\033[0m"); System.out.println("\033[4;31mError: " + e.getMessage() + "\033[0m");
} }