Use Java to code Chomp game. Chomp is a Nim-type game in which two players take bites of a gridded cookie in turn.  Each bite at a given row and column consumes the cookie at, below, and to the right of that position.  The player taking the last bite in the first row and first column loses. (https://en.wikipedia.org/wiki/Chomp). Please include these methods of Chomp game in your code when executing this function

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Use Java to code Chomp game.

Chomp is a Nim-type game in which two players take bites of a gridded cookie in turn.  Each bite at a given row and column consumes the cookie at, below, and to the right of that position.  The player taking the last bite in the first row and first column loses. (https://en.wikipedia.org/wiki/Chomp).

Please include these methods of Chomp game in your code when executing this function

 

Modifier and Type
boolean
boolean
int
int
int
boolean
boolean
java.lang.String
Method and Description
checkIfChomped (int row, int col)
Return whether or not the board has been chomped at o-based index position [row][col].
chompat (int row, int col)
If a chomp at [row][col] is legal, then (1) chomp all positions in the rectangle of positions with [row][col] being the upper-left-most and [rows-1][cols-1]
being the lower-right-most, (2) change the current player from 1 to 2 or vice versa, and (3) return true.
getCols ()
Get the number of columns in the board.
getCurrentPlayer()
Return the current player number, initially 1 and alternating between 1 and 2 with each successive legal play.
getRows()
Get the number of rows in the board.
isGameOver()
Return whether or not the game is over, that is, whether or not position [o][o] has been chomped.
isLegalChomp (int row, int col)
Return whether or not a chomp at [row][col] would be a legal chomp, that is, would be both in bounds and not previously chomped.
toString()
Return the String representation of the board, such that each line is terminated with a newline, the first line consists of a space and the digits o through
(cols-1) and following lines consist of the row index digit followed by asterisks/spaces representing unchomped/chomped positions, respectively.
Transcribed Image Text:Modifier and Type boolean boolean int int int boolean boolean java.lang.String Method and Description checkIfChomped (int row, int col) Return whether or not the board has been chomped at o-based index position [row][col]. chompat (int row, int col) If a chomp at [row][col] is legal, then (1) chomp all positions in the rectangle of positions with [row][col] being the upper-left-most and [rows-1][cols-1] being the lower-right-most, (2) change the current player from 1 to 2 or vice versa, and (3) return true. getCols () Get the number of columns in the board. getCurrentPlayer() Return the current player number, initially 1 and alternating between 1 and 2 with each successive legal play. getRows() Get the number of rows in the board. isGameOver() Return whether or not the game is over, that is, whether or not position [o][o] has been chomped. isLegalChomp (int row, int col) Return whether or not a chomp at [row][col] would be a legal chomp, that is, would be both in bounds and not previously chomped. toString() Return the String representation of the board, such that each line is terminated with a newline, the first line consists of a space and the digits o through (cols-1) and following lines consist of the row index digit followed by asterisks/spaces representing unchomped/chomped positions, respectively.
Constructor Detail
ChompGame
public ChompGame (int rows,
int cols)
Create an initial board with the given number of rows and columns with all positions unchomped.
Parameters:
rows the number of rows in the board
cols the number of columns in the board
Transcribed Image Text:Constructor Detail ChompGame public ChompGame (int rows, int cols) Create an initial board with the given number of rows and columns with all positions unchomped. Parameters: rows the number of rows in the board cols the number of columns in the board
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY