This is a project from a programming course (subject). If you come to watch because of your course (subject) assignment, DO NOT just copy and paste this code or just modify the variables name otherwise your score is possible to be penalised. Moreover, this project is divided into three parts and is completed with the progress of the course (subject). Therefore, different JAVA concepts will not be implemented in the same part, and the difficulty will be different.
This project will be devided into three parts. If you want to go to part2 and part3, here is the link below.
This project is the first in a series of three, with the ultimate objective of designing and implementing a simple variant of the game of Nim in Java. Nim is a two-player game, and the rules of the version used here are as follows:
- The game begins with a number of objects (e.g., stones placed on a table).
- Each player takes turns removing stones from the table.
- On each turn, a player must remove at least one stone. In addition, there is an upper bound on the number of stones that can be removed in a single turn. For example, if this upper bound is 3, a player has the choice of removing 1, 2 or 3 stones on each turn.
- The game ends when there are no more stones remaining. The player who removes the last stone, loses. The remaining player wins.
- Both the initial number of stones, and the upper bound on the number that can be removed, can be varied from game to game, and must be chosen before a game commences.
For this first project, the focus will be on creating two players and playing for multiple games by using basic jAVA concept. Therefore, there are no too much things to do.
- Your program will begin by displaying a welcome message.
- The program will then prompt for a string (no space in the string) to be entered via standard input (the keyboard) - this will be the name of Player 1. You may assume that all inputs to the program will be valid.
- The program will then prompt for another string (no space in the string) to be entered - this will be the name of Player 2.
- The program will then prompt for an integer to be entered - this will be the upper bound on the number of stones that can be removed in a single turn.
- The program will then prompt for another integer to be entered - this will be the initial number of stones.
- The program will then print the number of stones, and will also display the stones, which will be represented by *.
- The program will then prompt for another integer to be entered - this time, a number of stones to be removed. Again, you may assume this input will be valid and will not exceed the number of stones remaining or the upper bound on the number of stones that can be removed.
- The program should then show an updated display of stones.
- The previous two steps should then be repeated until there are no stones remaining. When this occurs, the program should display ‘Game Over’, and the name of the winner.
- The program should then ask user whether the players wanted a play again. The user is prompted to enter ‘Y’ for yes or ‘N’ for no. If the user enters ‘Y’, that is, the user wants to play another game, repeat steps 4-10. Otherwise, the program should terminate. Note, any input apart from ’Y’ should terminate the game
University of Melbourne COMP90041 Subject
Received marks of this project: 10 / 10