My briljant Mastermind application
-
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();
}}
-
please tell us what it does, i'm not going to dig through that steaming pile of java (yet another language I despise) to figure it out
-
Yet another proof that the entire world boils down to a few if clauses...
-
Another thing.... just imagine the amount of if clauses needed if you d like to expand to 'Expert Mastermind' that has more variables...
-
What, am I supposed to count the wtfs?
-
[quote user="Nandurius"]What, am I supposed to count the wtfs?
[/quote]We could print such code on the back of cereal wrapping and let the kids find the wtfs.. lets call it WTF Trivia or something like that...
Okay okay 3 posts ... I ll go back to work..
-
You suck.
-
Is briljant the new brillant?
-
[quote user="djork"]You suck.[/quote]
Die.
-
-
It's a poor student implementation of mastermind.
You're off the hook 'cause no one payed you to write it, nor did you release it publicly.
-
[quote user="Nachoo"]
[quote user="Nandurius"]What, am I supposed to count the wtfs?
[/quote]We could print such code on the back of cereal wrapping and let the kids find the wtfs.. lets call it WTF Trivia or something like that...
[/quote]
How about borrowing Knuth's idea ?
We can have a competition to find the wtfs and double the prize money for every WTF found. Let's start at 1 cent.
[I hope there are less than 20 of them, in there.]
-
[quote user="Nachoo"][quote user="djork"]You suck.[/quote]
Die.[/quote]pulls up a chair and grabs his pointy stick
Marshmallow, anyone?
-
[quote user="djork"][quote user="Nachoo"][quote user="djork"]You suck.[/quote]
Die.[/quote]
Not you, the original poster.[/quote]
I shall excuse my sudden rush of anger and say sorry to ye.
I was just in a bad mood...
We can have a competition to find the wtfs and double the prize money for every WTF found. Let's start at 1 cent.
[I hope there are less than 20 of them, in there.]
Great idea... but I guess we will run into bankruptcy until lets say line 24 or something around that.
-
Does Ctrl+V still work on your keyboard? I would have done this to piss my CS teacher off, whom I didn't like very much.
On the brightside you can acknowledge what you did, which many cannot.
-
Please let us know how your teacher reacted when (s)he saw this