It was a schoolassignment to create a console mastermind application. After weeks of engineering I finally began the build this application.
So i threw all my designclasses away and created this.
/*
* Created on Sep 26, 2006
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package Main;
import java.io.*;
import java.lang.reflect.Array;
import java.util.*;
/**
* @author Bart
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class Game {
private static ArrayList List;
public static void main(String[] args) {
List = new ArrayList();
run();
}
public static void run()
{
int As = 0;
int Bs = 0;
int Cs = 0;
int Ds = 0;
int Count = 10;
int Count2 = 0;
boolean win = false;
int Am = (int) (4 * Math.random());
int Bm = (int) (4 * Math.random());
int Cm = (int) (4 * Math.random());
int Dm = (int) (4 * Math.random());
int Ab = Am;
int Bb = Bm;
int Cb = Cm;
int Db = Dm;
System.out.println(Am);
System.out.println(Bm);
System.out.println(Cm);
System.out.println(Dm);
System.out.println("New Game");
while (win == false) {
Count2++;
Am = Ab;
Bm = Bb;
Cm = Cb;
Dm = Db;
BufferedReader inkbd = new BufferedReader(new InputStreamReader(System.in));
try {
As = Integer.parseInt(inkbd.readLine());
Bs = Integer.parseInt(inkbd.readLine());
Cs = Integer.parseInt(inkbd.readLine());
Ds = Integer.parseInt(inkbd.readLine());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
System.out.println("resultaat");
if (Am == As & Bm == Bs & Cm == Cs & Dm == Ds)
{
System.out.println("je hebt gewonnen");
win = true;
As = 10;
Bs = 10;
Cs = 10;
Ds = 10;
}
if (Count2 >= 8 & win == false)
{
System.out.println("mislukt");
win = true;
As = 10;
Bs = 10;
Cs = 10;
Ds = 10;
}
if (Am == As)
{
System.out.println("zwart");
Am = Count;
As = Count;
Count++;
}
if (Bm == Bs)
{
System.out.println("zwart");
Bm = Count;
Bs = Count;
Count++;
}
if (Cm == Cs)
{
System.out.println("zwart");
Cm = Count;
Cs = Count;
Count++;
}
if (Dm == Ds)
{
System.out.println("zwart");
Dm = Count;
Ds = Count;
Count++;
}
if (Am == Bs)
{
System.out.println("wit");
Am = Count;
Bs = Count;
Count++;
}
if (Am == Cs)
{
System.out.println("wit");
Am = Count;
Cs = Count;
Count++;
}
if (Am == Ds)
{
System.out.println("wit");
Am = Count;
Ds = Count;
Count++;
}
if (Bm == As)
{
System.out.println("wit");
Bm = Count;
As = Count;
Count++;
}
if (Bm == Cs)
{
System.out.println("wit");
Bm = Count;
Cs = Count;
Count++;
}
if (Bm == Ds)
{
System.out.println("wit");
Bm = Count;
Ds = Count;
Count++;
}
if (Cm == As)
{
System.out.println("wit");
Cm = Count;
As = Count;
Count++;
}
if (Cm == Bs)
{
System.out.println("wit");
Cm = Count;
Bs = Count;
Count++;
}
if (Cm == Ds)
{
System.out.println("wit");
Cm = Count;
Ds = Count;
Count++;
}
if (Dm == As)
{
System.out.println("wit");
Dm = Count;
As = Count;
Count++;
}
if (Dm == Bs)
{
System.out.println("wit");
Dm = Count;
Bs = Count;
Count++;
}
if (Dm == Cs)
{
System.out.println("wit");
Dm = Count;
Ds = Count;
Count++;
}
}
List.add(Integer.toString(Count2));
System.out.println("score");
System.out.println(List);
run();
}
}