Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,39 @@
public abstract class AbstractGuessNumber {
protected int[] digits;
private int length;
public AbstractGuessNumber(int length) {
this.length = length;
this.digits = new int[this.length];
}
public int[] getDigits() {
return digits;
}
public int getLength() {
return length;
}
public GuessResult match(AbstractGuessNumber guessable) {
int bulls = 0;
int cows = 0;
if (guessable != null) {
for (int i = 0; i < this.getLength(); i++) {
for (int j = 0; j < guessable.getLength(); j++) {
if (digits[i] == guessable.getDigits()[j]) {
if (i == j) {
bulls++;
} else {
cows++;
}
}
}
}
}
return new GuessResult(getLength(), bulls, cows);
}
}