Problem 1 - Implementing a simple game Game This is game where two players alternately take cards from a deck of cards. In each move, a player chooses how many cards to take in his/her turn the player must take at least one but not more than half of the cards a valid value). Then the next player takes turn. The player who takes the final card loses You are asked to write a program in which the computer plays against a human opponent. Your program, at the beginning should ask the number of cards in the deck, the human player enters an integer computer playing mode the user enters for stupid, for smart mode, I invalid int value entered asks again asks who starts first, the user enters for human 1 for computer. It invalid int value entered asks again At each turn your program prints the number of remaining cards. If it is human's turn, the program asks the number of cards to be removed. and it check if it is a valid integer value, keeps asking until the human player enters a valid input The computer plays in two modes: stupid.removes a random number (validy of cards smart removes enough cards to make the remaining number of cards 2n-1, that is 3.7. 15, 31, 63 etc. with a valid move, except if the number of cards is currently one less than a power of 2. In that case a random number (valid) of cards are removed Classes/Methods Your implementation are constrained with the following has two classes Game and Computer (see how the main method invokes Game class method) . We will check for style indentation, variable naming conventions (camel case) etc. . In addition to the public methods, Game class should have some helper methods (private). This is due to top-down refinement. You don't want to put overyting in one big method. We expect at least one helper method Computer cast represents computer player Demonstrate while and do while use while iteration construct in reading computer mode, a do-while construct in the part getting the player tum (repeatedly asking until a valid int vlage entered) Computer has a booelan instance variable to remember if it is playing stupid or smart mode have setter and getter method for the instance variables Computer dass has the following public method 1 plays one turn W paranter numberOfCards - is the current number of cards in the deck W returns the number of cards to be removed int play(int number of Cards) A sample output Enter number of cards:1ee Enter e if the computer plays in stupid mode, 1 for smart mode:1 Computer is playing in smart mode Enter e if the human stars, 1 if computer starts: 0 e There are 100 cards left Your turn. How many you want to remove: 58 There are 5e cards left Computer removed 19 cards There are 31 cards left Your turn. How many you want to remove: 15 There are 16 cards left Computer removed 9 cards There are 7 cards left Your turn. How many you want to remove: 1 There are 6 cards left Computer removed 3 cards There are 3 cards left Your turn. How many you want to remove:1 There are 2 cards left Computer removed 1 cards Computer wins 2 public class LabiMain { 3 private static final int SUM=15; // for in-lab exercise 4 50 public static void main(String[] args) { 6 gameDemo(); 7 extraDemo(); } 9 18 11e public static void gameDemo() { 12 // uncomment below to test your Game class 13 // Game game = new Game(); 14 //game.play(); 15 } 16 17 18e 19 28 21 public static void extraDemo () { 1/ In-lab assignments. 1 add method calls to test your in-lab questions. 22 } // add methods for in-lab questions below 23 24 25 26 ) 27 Probleme lavadoc Declaration Console Git Staging Problem 1 - Implementing a simple game Game This is game where two players alternately take cards from a deck of cards. In each move, a player chooses how many cards to take in his/her turn the player must take at least one but not more than half of the cards a valid value). Then the next player takes turn. The player who takes the final card loses You are asked to write a program in which the computer plays against a human opponent. Your program, at the beginning should ask the number of cards in the deck, the human player enters an integer computer playing mode the user enters for stupid, for smart mode, I invalid int value entered asks again asks who starts first, the user enters for human 1 for computer. It invalid int value entered asks again At each turn your program prints the number of remaining cards. If it is human's turn, the program asks the number of cards to be removed. and it check if it is a valid integer value, keeps asking until the human player enters a valid input The computer plays in two modes: stupid.removes a random number (validy of cards smart removes enough cards to make the remaining number of cards 2n-1, that is 3.7. 15, 31, 63 etc. with a valid move, except if the number of cards is currently one less than a power of 2. In that case a random number (valid) of cards are removed Classes/Methods Your implementation are constrained with the following has two classes Game and Computer (see how the main method invokes Game class method) . We will check for style indentation, variable naming conventions (camel case) etc. . In addition to the public methods, Game class should have some helper methods (private). This is due to top-down refinement. You don't want to put overyting in one big method. We expect at least one helper method Computer cast represents computer player Demonstrate while and do while use while iteration construct in reading computer mode, a do-while construct in the part getting the player tum (repeatedly asking until a valid int vlage entered) Computer has a booelan instance variable to remember if it is playing stupid or smart mode have setter and getter method for the instance variables Computer dass has the following public method 1 plays one turn W paranter numberOfCards - is the current number of cards in the deck W returns the number of cards to be removed int play(int number of Cards) A sample output Enter number of cards:1ee Enter e if the computer plays in stupid mode, 1 for smart mode:1 Computer is playing in smart mode Enter e if the human stars, 1 if computer starts: 0 e There are 100 cards left Your turn. How many you want to remove: 58 There are 5e cards left Computer removed 19 cards There are 31 cards left Your turn. How many you want to remove: 15 There are 16 cards left Computer removed 9 cards There are 7 cards left Your turn. How many you want to remove: 1 There are 6 cards left Computer removed 3 cards There are 3 cards left Your turn. How many you want to remove:1 There are 2 cards left Computer removed 1 cards Computer wins 2 public class LabiMain { 3 private static final int SUM=15; // for in-lab exercise 4 50 public static void main(String[] args) { 6 gameDemo(); 7 extraDemo(); } 9 18 11e public static void gameDemo() { 12 // uncomment below to test your Game class 13 // Game game = new Game(); 14 //game.play(); 15 } 16 17 18e 19 28 21 public static void extraDemo () { 1/ In-lab assignments. 1 add method calls to test your in-lab questions. 22 } // add methods for in-lab questions below 23 24 25 26 ) 27 Probleme lavadoc Declaration Console Git Staging