Hello, i am having with my mastermind game. I try to display black and white pegs but it does not work. Right now i gave up on black pegs and i am trying whitepegs.
import java.io.*;
import java.io.*;
public class Mastermind
{
int a = 0;
int p = 0;
int x = 0;
int gen1 = 0;
int gen2 = 0;
int gen3 = 0;
int gen4 = 0;
int gen = 0;
int black = 0;
String s = "";
int[] getinput = new int[4];
int[] getnumbers = new int[4];
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
// the generated code
public void generate()
{
for (int counter = 0; counter < 4; counter ++)
{
double number = 0;
number = Math.random();
System.out.println();
int dice = 0;
dice = (int)(Math.random() * 4) + 1;
System.out.print(dice);
getnumbers[p] = dice;
}
}
//end of generated code
public void input()
{
try
{
String s = "";
System.out.println("Enter 4 colours:");
//get names from user
//store in array 'getnames'
do{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
s = br.readLine();
Integer.parseInt(s); //takes away the quotations
getinput[x] = x;
x++;
}while(x < 4);
}
catch (IOException ex)
{
ex.printStackTrace();
}
}
public int pegs()
{
if(getinput[x]==getnumbers[x])
{
black++;
}
return black;
}
public void print()
{
System.out.println(black);
}
}
And my runner
public class Mastermindrunner
{
public static void main (String[] args)
{
Mastermind black = new Mastermind();
black.generate();
black.input();
black.pegs();
black.pegs();
}
}