Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To pass the time during long voyages, Viking sailors would play the two-player game of Hemnesbrim . In this assignment, you'll implement the game, but

To pass the time during long voyages, Viking sailors would play the two-player game of Hemnesbrim. In this assignment, you'll implement the game, but play will be against the computer.

During each round, players choose a move, which may be either Knoppng, Bjrnarp, Grnby, or Vilshult. The rules are:

Knoppng beats Bjrnarp and Grnby

Bjrnarp beats Grnby

Grnby beats Vilshult

Vilshult beats Knoppng and Bjrnarp

The computer wins in the event of a tie.

Your program should behave as follows:

The rules should be printed to the screen

The user is asked if they'd like to play a round

if they choose 'y', a round is played

if they choose 'n', the program ends

Until the user has chosen to quit, another round is played.

In a round of play:

The user is asked to enter a move, which may be either 'B'jornarp, 'G'ronby, 'K'noppang, or 'V'ilshult. The program should continue to prompt the user until a valid move is entered.

The computer makes a move at random. (Hint: remember how we generated random numbers in class.)

The program prints the computer's move, the user's move, and who is the winner of this round.

The user is asked if they'd like to continue.

When the user has decided to quit the game, the program prints the number of:

rounds played

times the user won

times the computer won

suggestions

testing (15 points)

Remember that good code is readable and testable. In order to receive full credit for this assignment, you'll need to break up the problem into at least 5 methods separate from main( ). Develop and submit JUnit tests for at least two of these.

Recall that to create most of the skeleton of these tests for yourself, in Netbeans you can right-click (CMD-click on a Mac) on name of your Java source file in the project view, then Tools, then Create/Update Tests. The test file may then be found under the Test Packages folder.

Some functions that we've used that should be helpful are:

assertEquals

assertTrue

assertFalse

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Deductive And Object Oriented Databases Second International Conference Dood 91 Munich Germany December 18 1991 Proceedings Lncs 566

Authors: Claude Delobel ,Michael Kifer ,Yoshifumi Masunaga

1st Edition

3540550151, 978-3540550150

More Books

Students also viewed these Databases questions

Question

Tell the merits and demerits of Mendeleev's periodic table.

Answered: 1 week ago