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

In this problem, you will write a program to play as the \"code-guesser\" in the

ID: 3598417 • Letter: I

Question

In this problem, you will write a program to play as the "code-guesser" in the game of Masetermind. For simplicity, this game of Mastermind has four colors (not six, as usual) and three positions (not four, as usual). The colors are Red, Blue, Orange, and White. This means that there are only 64 possible codes. Your program should allow you (as user) to think of a "secret" code. The program will thern make successive guesses at the code, and you answer with X and O responses as in the standard MasterMind game. The program should simply keep track of the current set of "open" guesses consistent with the answers so far; you can then decide how the next gues:s can be selected. When the game starts, the program has 64 "open" possibilities; each answered guess should narrow the possibilities. Here's an example. Suppose you think of the code: RR W. The program might begin by asking:

Explanation / Answer

package com.one;

abstract class Polynomial {

DList<Term> data = null;

public Polynomial() {

data = new DList<>();

}

public final String toString() {

String ans = "";

boolean starting = true;

try {

DNode<Term> n = data.getFirst();

while (n != null) {

if (!starting && n.getData().isPositive())

ans += " +";

starting = false;

ans += " " + n.getData().toString();

n = data.getNext(n);

}

} catch (Exception e) {

if (starting)

return "0";

}

return ans;

}

abstract public Polynomial add(Polynomial p);

abstract public Polynomial subtract(Polynomial p);

abstract public Polynomial multiply(Polynomial p);

abstract public Polynomial divide(Polynomial p) throws Exception;

abstract public Polynomial remainder(Polynomial p) throws Exception;

}

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