
-----------------------------------
S_Grimm
Tue Dec 09, 2008 6:58 pm

Mastermind V1.0
-----------------------------------
So......

Mastermind. For those of you who don't know what it is, it is a game where you guess the numbers.

This version is a four number version. (as in guess 4 numbers ie 8862 or 1497). I would love suggestions on how to improve the code.

Next Version to include: GUI interface. Instead of numbers, colors!

BTW: If anyone in my class (rto) takes this and submits it as there own......


/***********************
 * The Mastermind Game *
 *                     *
 * Shane Grimminck     *
 * Copyright 2008      *
 ***********************/

import java.io.*;

public class mastermind
{
    public static void main (String

-----------------------------------
Tony
Tue Dec 09, 2008 7:06 pm

RE:Mastermind V1.0
-----------------------------------
You have a lot of repeating code. Instead of

if (masterChar [0] == 'a')
if (masterChar [1] == 'a')
...

where each block has a redundant block of code, you can iterate over the conditions with a for-loop.

Same goes for your 4 copies of the "for (int i = 0 ; i < 4 ; i++)" loops.

-----------------------------------
S_Grimm
Tue Dec 09, 2008 7:22 pm

RE:Mastermind V1.0
-----------------------------------
the "for (int i = 0; i < 4; i++){}" loops are separate so that they individually check. Stupid way to do it, I know, but it works. The "if masterChar..." stuff I will change though.

-----------------------------------
Tony
Tue Dec 09, 2008 7:26 pm

RE:Mastermind V1.0
-----------------------------------

for(int j=0; j < 4; j++){
  for (int i = 0 ; i < 4 ; i++)
  {
    if ((masterChar 
no?

-----------------------------------
S_Grimm
Tue Dec 09, 2008 7:35 pm

RE:Mastermind V1.0
-----------------------------------
lol. I am reaaaally stupid. thanks tony. What did that just cut out? ummm..

57. wow. Just wow. Thanks Tony.

Heres the updated copy


/***********************
 * The Mastermind Game *
 *  v2                   *
 * Shane Grimminck     *
 * Copyright 2008      *
 ***********************/
 
 //Thanks to Tony for helping shorten this to 97 lines instead of 141

import java.io.*;

public class mastermind2
{
    public static void main (String

-----------------------------------
S_Grimm
Tue Dec 09, 2008 7:36 pm

RE:Mastermind V1.0
-----------------------------------
Actually, I don't think that i need the boolean statements either.......


edit. Nvrmind i do need them. Anyone have any other suggestions?

-----------------------------------
rto
Wed Dec 17, 2008 9:10 am

RE:Mastermind V1.0
-----------------------------------
God this program is completely and utterly garbage -.-

haha jk, goodly done :)

-----------------------------------
S_Grimm
Wed Dec 17, 2008 11:19 am

RE:Mastermind V1.0
-----------------------------------
Well considering MINE is completed AND handed in to the teacher and YOURS still isn't.......... I'd say mine is better than yours.

jk.
