Skip to content

This is a Nim Game project from a programming course and this is the first part of this project.

Notifications You must be signed in to change notification settings

ZavierYang/NimGame_project1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 

Repository files navigation

Importance

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.

NimGame_Project1

This project will be devided into three parts. If you want to go to part2 and part3, here is the link below.

Go to Project 2

Go to Project 3

Game of Strategy

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:

  1. The game begins with a number of objects (e.g., stones placed on a table).
  2. Each player takes turns removing stones from the table.
  3. 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.
  4. The game ends when there are no more stones remaining. The player who removes the last stone, loses. The remaining player wins.
  5. 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.

Aim of Project1: Implement Nim’s Basic Game Mechanics

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.

  1. Your program will begin by displaying a welcome message.
  2. 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.
  3. The program will then prompt for another string (no space in the string) to be entered - this will be the name of Player 2.
  4. 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.
  5. The program will then prompt for another integer to be entered - this will be the initial number of stones.
  6. The program will then print the number of stones, and will also display the stones, which will be represented by *.
  7. 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.
  8. The program should then show an updated display of stones.
  9. 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.
  10. 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

Source

University of Melbourne COMP90041 Subject

Received marks of this project: 10 / 10

About

This is a Nim Game project from a programming course and this is the first part of this project.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages