Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the Web service which represents a number guessing game. The game has the following methods: @WebMethod(operationName = startGame) public synchronized String startGame() @WebMethod(operationName =

Implement the Web service which represents a number guessing game. The game has the following methods:

@WebMethod(operationName = "startGame")

public synchronized String startGame()

@WebMethod(operationName = "playGame")

public synchronized String playGame(@WebParam(name = "num") int num)

When the startGame() method is called, a random integer between 0 and 100 inclusively is generated. The returned string of the method is "game started". The player has to guess the number by invoking the playGame() method. The guessed number is passed as the parameter to the method. The player has five times to make a correct guess. The returned string of the method is:

  1. if no correct guess has been made:
    1. if the number of guesses made (excluding the current one) is less than 5:
      1. if the guess is correct, then the returned string is: "correct", otherwise, the returned string is "should be greater" or "should be less" depending on the actual integer is greater or less than the provided guess.
    2. if the number of guesses made (including the current one) is greater than 5, the string returned is "You have made more than 5 guesses".
  2. If a correct guess has been made, then the returned string is "A correct guess has been made already".

Complete the following incomplete code for the Web service:

@WebService(serviceName = "Game")

public class Game {

//**** attributes in the class:

.........

@WebMethod(operationName = "startGame")

public synchronized String startGame() {

//**** implementation of startGame()

...........

}

@WebMethod(operationName = "playGame")

public synchronized String playGame(@WebParam(name = "num") int num) {

//***** implementation of playGame

...........

}

}

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

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions

Question

Additional Factors Affecting Group Communication?

Answered: 1 week ago