Merge remote-tracking branch 'origin/main'

# Conflicts:
#	src/ch/zhaw/catan/Road.java
This commit is contained in:
Andrin Fassbind 2021-12-10 11:14:24 +01:00
commit 1b6983dace
2 changed files with 24 additions and 17 deletions

View File

@ -4,10 +4,10 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
* This class is here in order to maintain the resources of the players, the amount of structures that they can build, * This class is here in order to maintain the resources of the players, the amount of structures that they can build.
* control to see if a player has enough to build a new structure and to add them into a faction. * And check if a player holds enough resources to build.
* *
* @author Leonardo Brandenberger, Roman Schrom, Andrin Fassbind, Stefan Amador * @author Leonardo Brandenberger, Roman Schenk, Andrin Fassbind, Stefan Amador
*/ */
public class Player { public class Player {
@ -18,7 +18,7 @@ public class Player {
/** /**
* The constructor initializes the faction and the Hashmaps resources and structureToUse. * The constructor initializes the faction and the Hashmaps resources and structureToUse.
* *
* @param faction this is the faction of the player. * @param faction faction of the player.
*/ */
public Player(Config.Faction faction) { public Player(Config.Faction faction) {
//Data fields //Data fields
@ -36,7 +36,7 @@ public class Player {
} }
/** /**
* This method returns all the resources the player has at the moment * This method returns all the resources the player has at the moment.
* *
* @return HashMap with the count of every resource * @return HashMap with the count of every resource
*/ */
@ -45,7 +45,7 @@ public class Player {
} }
/** /**
* This method returns player faction * This method returns the player's faction.
* *
* @return the faction of the player. * @return the faction of the player.
*/ */
@ -56,15 +56,15 @@ public class Player {
/** /**
* This method returns the amount of a specific resource that a player owns. * This method returns the amount of a specific resource that a player owns.
* *
* @param resource the resource that is needed. * @param resource the resource that is needed
* @return the amount of the specific resource. * @return the amount of the specific resource
*/ */
public int getSpecificResource(Config.Resource resource) { public int getSpecificResource(Config.Resource resource) {
return resources.get(resource); return resources.get(resource);
} }
/** /**
* This method adds a specific resource to resources * This method adds a specific resource to resources of the player.
* *
* @param resource to add * @param resource to add
* @param numberToAdd how much to add * @param numberToAdd how much to add
@ -91,7 +91,7 @@ public class Player {
/** /**
* This method has to be used when a player wants to build a structure. It checks if a player has enough of the specific structure * This method has to be used when a player wants to build a structure. It checks if a player has enough of the specific structure
* and resources to build one more. If the player is able to build, this method subtracts the building cost from the resources * and resources to build . If the player is able to build, this method subtracts the building cost from the resources
* in possession by the player. * in possession by the player.
* It reduces the amount of the specific structure a player can build by 1. * It reduces the amount of the specific structure a player can build by 1.
* *

View File

@ -2,9 +2,12 @@ package ch.zhaw.catan;
import java.awt.Point; import java.awt.Point;
/** /**
* sub Class of Structure * Sub Class of Structure
* Can be saved in Siedler Board on Edges. * Can be saved in Siedler Board on Edges.
*
* @author Andrin Fassbind, Michael Ziegler
*/ */
public class Road extends Structure { public class Road extends Structure {
@ -12,11 +15,11 @@ public class Road extends Structure {
private final Point start, end; private final Point start, end;
/** /**
* Constructor of Road * Constructs a road with a start and endpoint.
* *
* @param faction The faction of the owner * @param faction The faction of the road owner
* @param start the coordinates of the start Point * @param start the coordinates of the start as a Point
* @param end the coordinates of the End Point * @param end the coordinates of the end as a Point
*/ */
public Road(Config.Faction faction, Point start, Point end) { public Road(Config.Faction faction, Point start, Point end) {
super(faction); super(faction);
@ -25,14 +28,18 @@ public class Road extends Structure {
} }
/** /**
* @return the coordinates of the start Point * Returns the Coordinate as a Point of the start of the road.
*
* @return Point of the start of the road
*/ */
public Point getStart() { public Point getStart() {
return start; return start;
} }
/** /**
* @return the coordinates of the end Point * Returns the Coordinate as a Point of the end of the road.
*
* @return Point of the end of the road
*/ */
public Point getEnd() { public Point getEnd() {
return end; return end;