The purpose of this lab is for you to familiarize yourself with using methods in Java. In this lab, you will create your own methods that implement the logic of the game described below. Objective You are going to make a simple baseball-themed number guessing game. There should be 2 Players: Player 1 and Player 2. Player 1 has a secret 3 digit number in mind. Player 2 must guess the number that Player 1 has in mind. After the guess, Player1 should say the result of the guess. The three digit number should be distinct, meaning that no duplicate digits are allowed in the number, ex: 774, 747 For example, Player1 has 735 in mind as the secret number. If Player2 guesses 236 then Player 1 says ‘one strike’. Because it has 3, and it is in the same position (the tens place) as the secret number If Player2 guesses 123 then the output is ‘one ball’.
Because it contains a 3, but not at the right position. If Player2 guesses 539 then the output is: ‘one ball and one strike’. Because it has 3 at the same position but 5 different position. If Player2 guesses 738 then the output is ’two strikes’. If Player2 guesses 124 then the output is ‘nothing’ If Player2 guesses 357 then the output is ‘three balls’ If Player2 guesses 735 then the output is ‘three strikes’ and game is over. Simply, you generate a random number which is 3 digit number and enter your guess using “Scanner”. Then your code needs to respond to the guess until you get ‘three strikes’.
mardi 18 octobre 2016
I have absolutely no clue how to go about doing this. Any help is greatly appreciated
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire