Game

3 respostas
A

Ola Bom dia, estou precisando de uma ajudinha para desenvolver um game para a faculdade, estou perdida, sera que alguem conseguiria me ajudar? Obrigada desde ja :slight_smile:

O começo do jogo é o seguinte (estou perdida desde aqui já) :frowning:

At the start of the game, the user should be asked to enter the number of players in the game.
-There has to be a minimum of 2 players and a maximum of 4 Players
-The player has to enter their name in one line and must enter a first name and surname
-The player’s age must be 12 or over

Each player should be awarded 100 “Pirate Points” to start the game. Then the game should randomly give each player a number of “Dig Points”

  • The number of “Dig Points” must be a minimum of 4 and a maximum of 7.

Now subtract “Pirate Points” from each player based on their “Dig Points” x 5 – for example, if Player One gets 3 Dig Points, then subtract 3 x 5 = 15 from their “Pirate Points”, so Player One now has 85 “Pirate Points” at the start of the game.

The game should then create a “Treasure Map” and display it on the screen. This will be a 10 x 10 grid of squares. The grid must be labelled so that the rows are numbered 1 to 10 and the columns are labelled A to J. This is so that the player can easily select a square.

3 Respostas

Lucas_Camara

Para fazer essa parte, pensando simples, vc pode usar a classe Scanner para ler a entrada de dados pelo teclado.

A

Obrigada Lucas pela ajuda

Agora meu codigo esta dando no while acredito

public static void main(String[] args) {
	int numPlayers;
	
	// ArrayList<String> players = new ArrayList();
	// ArrayList<Integer> scores = new ArrayList();
	
	System.out.println("Welcome to the Pirate Peter's Treasure Hunt Game, are you ready for this adventure? ");
	
	do {
		Scanner sc = new Scanner(System.in); //take the information from the user
		
		System.out.println("Please enter the number of players between 2 and 4: "); //show the instructions
		numPlayers = sc.nextInt();
		
		if ((numPlayers == 2) || (numPlayers == 3) || (numPlayers == 4)) { //check if the number of players are between 2 and 4
			System.out.println("ARGH! What's the name of the Pirate? ");
			numPlayers = sc.nextInt();
		} else {
			System.out.println("OH God! This number of players are not right! Enter a number between 2 and 4: ");
			numPlayers = sc.nextInt();
		}
	} while (numPlayers == 2 || numPlayers == 3 || numPlayers == 4);
	
	{
		for (i = 0; i < playerCount; i++) {
			System.out.println("Enter player " + (i + 1) + " 's name: ");
		}
		
		if (playerCount == 2 || playerCount <= 4) {
		
		} else {
			System.out.println("Please enter the number of players between 2 and 4");
		}
		
		break;
	}
Lucas_Camara

Tem algumas coisas estranhas no seu código.

Essa parte solicita um nome, porém o nextInt é usado (que obtém um número em vez de uma String)

  • Tem umas chaves { sobrando nessa parte
  • No for tem um solicitação para entrar com o nome, porém não é atribuida à nenhuma variável
  • Tem if sem corpo
  • Tem um break perdido ali no final
Criado 30 de abril de 2020
Ultima resposta 30 de abr. de 2020
Respostas 3
Participantes 2