Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a class named SimpleGuesser. Think of it as a super simple version of the

ID: 3732268 • Letter: W

Question

Write a class named SimpleGuesser. Think of it as a super simple version of the NumberGuesser.

It should have a one argument constructor that accepts an int. This int should be the initial guess. When it is first created its getCurrentGuess() should return that initial value.

It should have a no-argument constructor. If a SimpleGuesser is created with this no argument constructor then its first guess should be 0.

It should have higher() and lower() methods. Whenever higher() is invoked the current guess should go up by one.

Whenever lower() is invoked the current guess should go down by one.

Here are the public constructors and methods that you class should have:

You can use any private fields or methods that you choose.

Explanation / Answer

public class SimpleGuesser { private int currentGuess; public SimpleGuesser() { this.currentGuess = 0; } public SimpleGuesser(int initialGuess) { this.currentGuess = initialGuess; } public int getCurrentGuess() { return currentGuess; } public void higher() { currentGuess++; } public void lower() { currentGuess--; } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote