Skip to content
Snippets Groups Projects
Commit 6d0a8053 authored by Isabell Hans's avatar Isabell Hans
Browse files

selfPossible integrated in other method

parent 9a9b65ae
No related branches found
No related tags found
No related merge requests found
......@@ -83,39 +83,6 @@ public class Card {
public void play(Scanner scanner, ArrayList<Player> players, Player turn, Deck deck, Card firstCard) {
}
/**
* This method is used to select a player which can also be the current player
*
* @param scanner The scanner used in the calling method
* @param players The list of players to play with
* @param turn The player whose turn it is
* @return The choosen player
*/
public Player choosePlayerInclSelf(Scanner scanner, ArrayList<Player> players, Player turn) {
if (!playerExists(players, turn)) {
System.out.println("There are no players to choose from. Your card is discarded without effect.");
return null;
}
System.out.println("Who do you choose?");
String name = scanner.nextLine();
boolean found = false;
while (!found) {
for (Player p : players) {
if (p.getName().equals(name) && !p.isProtected() && p.isActive()) {
Player player = players.get(players.indexOf(p));
found = true;
if (p.equals(turn)) {
System.out.println("You selected yourself");
}
return player;
}
}
System.out.println("You can't choose this one. Try again: ");
name = scanner.nextLine();
}
return null;
}
/**
* This method is used to select a player which cannot be the player whose turn
* it is
......@@ -123,6 +90,7 @@ public class Card {
* @param scanner The scanner used in the calling method
* @param players The list of players to play with
* @param turn The player whose turn it is
* @param selfPossible True if the player is allowed to select his/her self
* @return The choosen player
*/
public Player choosePlayer(Scanner scanner, ArrayList<Player> players, Player turn, boolean selfPossible) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment