For this task you will need to implement a Guesses class, which will store all of the locations that a player has targeted/guessed so far. Again, the included Runner class is provided purely so you can manually debug your code by hitting the Run button and observing the results. It is not included in any tests, so feel free to make any changes you like to it. Your workspace for this task includes a compiled Cell class, that has been implemented according to the specification described in Part 1.   Specification We have started you off with the skeleton of the Guesses class. Your task is to complete this class so that it has the following methods: A constructor that accepts no parameters, and results in a new instance of Guesses being created. An addGuess method, which accepts an instance of Cell, and returns nothing. Calling this method should result in this instance of Guesses remembering that the given location has been guessed. An isGuessed method, which accepts an instance of Cell, and returns either true or false depending on whether the given location has been previously guessed or not. A getTotalGuesses method, which accepts no parameters, and returns the number of guesses that have previously been made. This number should only go up when new valid guesses are made. If addGuess is called with an invalid location, or a location that has previously been guessed, then the number should remain unchanged. All of these methods should be public and not static. There should not be any other public methods or properties, but you are welcome to add any private properties and methods that you feel are necessary/helpful.   Runner: import java.util.Scanner ; public class Runner { public static void main(String[] args) { Scanner input = new Scanner(System.in) ; Guesses guesses = new Guesses() ; //add a valid guess guesses.addGuess(new Cell(0,0));    //add the same guess guesses.addGuess(Cell.fromString("A1")) ; //add an invalid guess guesses.addGuess(new Cell(8,0)); //There should be one valid guess System.out.println("You have made " + guesses.getTotalGuesses() + " valid, distinct guesses") ;    while (true) { System.out.println("Please enter a guess:") ; Cell guess = Cell.fromString(input.nextLine()); if (guess == null) { System.out.println("Invalid guess"); continue ; } if (guesses.isGuessed(guess)) { System.out.println("You have guessed this already!") ; } guesses.addGuess(guess) ; System.out.println("You have made " + guesses.getTotalGuesses() + " valid, distinct guesses") ; } } } Gusses code (required): public class Guesses { //Your code here    }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

For this task you will need to implement a Guesses class, which will store all of the locations that a player has targeted/guessed so far.

Again, the included Runner class is provided purely so you can manually debug your code by hitting the Run button and observing the results. It is not included in any tests, so feel free to make any changes you like to it.

Your workspace for this task includes a compiled Cell class, that has been implemented according to the specification described in Part 1.

 

Specification

We have started you off with the skeleton of the Guesses class. Your task is to complete this class so that it has the following methods:

A constructor that accepts no parameters, and results in a new instance of Guesses being created.

An addGuess method, which accepts an instance of Cell, and returns nothing. Calling this method should result in this instance of Guesses remembering that the given location has been guessed.

An isGuessed method, which accepts an instance of Cell, and returns either true or false depending on whether the given location has been previously guessed or not.

A getTotalGuesses method, which accepts no parameters, and returns the number of guesses that have previously been made. This number should only go up when new valid guesses are made. If addGuess is called with an invalid location, or a location that has previously been guessed, then the number should remain unchanged.

All of these methods should be public and not static. There should not be any other public methods or properties, but you are welcome to add any private properties and methods that you feel are necessary/helpful.

 

Runner:

import java.util.Scanner ;

public class Runner {

public static void main(String[] args) {

Scanner input = new Scanner(System.in) ;

Guesses guesses = new Guesses() ;

//add a valid guess
guesses.addGuess(new Cell(0,0));
  
//add the same guess
guesses.addGuess(Cell.fromString("A1")) ;

//add an invalid guess
guesses.addGuess(new Cell(8,0));

//There should be one valid guess
System.out.println("You have made " + guesses.getTotalGuesses() + " valid, distinct guesses") ;
  

while (true) {

System.out.println("Please enter a guess:") ;
Cell guess = Cell.fromString(input.nextLine());

if (guess == null) {
System.out.println("Invalid guess");
continue ;
}

if (guesses.isGuessed(guess)) {
System.out.println("You have guessed this already!") ;
}

guesses.addGuess(guess) ;

System.out.println("You have made " + guesses.getTotalGuesses() + " valid, distinct guesses") ;
}
}
}

Gusses code (required):

public class Guesses {

//Your code here
  

 

 

 

Examples
Here is an example of what the output of the Runner class might look like if you left it unchanged.
and your Guesses class was implemented correctly:
You have made 1 valid, distinct guesses
Please enter a guess:
A1
You have guessed this already!
You have made 1 valid, distinct guesses
Please enter a guess:
A2
You have made 2 valid, distinct guesses
Transcribed Image Text:Examples Here is an example of what the output of the Runner class might look like if you left it unchanged. and your Guesses class was implemented correctly: You have made 1 valid, distinct guesses Please enter a guess: A1 You have guessed this already! You have made 1 valid, distinct guesses Please enter a guess: A2 You have made 2 valid, distinct guesses
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Fibonacci algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education