Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Please help with my new memory board game excercise, been trying for 1 whole week and still can't finish this..:(

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please help with my new memory board game excercise, been trying for 1 whole week and still can't finish this..:(

    Create an application with following requirements:
    Input the length and width of board game manually.
    Width must be an even number, and the max width must be equal to 40/length. For example: length input is 10, thus the maximum input number for width is 4.
    The maximum size for memory board game (length*width) is 40
    Program will do randomize symbols inside “Memory Board Game” for each square board. There will be only 2 same symbols for each symbol picture.
    User will be ask to guess the location of 2 match symbol inside ‘Memory Board Game’.
    User gets only 10 chances to guess all the match symbols.
    If user guess correctly, the symbols will be opened.
    If user guess wrongly, the chance will be deducted by one.
    If user finish the chance before guessing all the match symbol, show a message of “You Lose”.
    If user able to guess all the match symbols with available chance, show a message of “You Win”
    Show user’s score with following formula:
    Score = chance * grade
    Grade = opened symbols * 10
    By the end of game, prompt user if she/he wants to re-play the game.


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Please help with my new memory board game excercise, been trying for 1 whole week and still can't finish this..:(

    Welcome jnesha1990
    What did you end up with after that week?
    What seems to be the problem with it?

  3. #3
    Junior Member
    Join Date
    May 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please help with my new memory board game excercise, been trying for 1 whole week and still can't finish this..:(

    Quote Originally Posted by jps View Post
    Welcome jnesha1990
    What did you end up with after that week?
    What seems to be the problem with it?
    hmm..i can't seem to start making this coding...can you please help me..i've been trying for like 1 whole week and really wanted to finished this ASAP
    i end up with coding that keep going on and on with the looping and kind a confuse about making the array because the user are prompt to enter the length and width manually...
    can you please help me with simple java coding to this? i will really appreciate it..thanks

    --- Update ---

    Quote Originally Posted by phanhuong900387 View Post
    Lên cho mọi người thấy...
    sorry i can't really understand you...

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Please help with my new memory board game excercise, been trying for 1 whole week and still can't finish this..:(

    Post the code that has problems, in code tags. (Instructions on the Announcements page) if you need help.
    Explain what the code is supposed to do.
    Explain what the code actually does.
    Include the full text of error messages with your post.

    As it stands your thread says "do my work for me", we would much rather see you finish your work, but are happy to help explain things when you get stuck

  5. #5
    Junior Member
    Join Date
    May 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Please help with my new memory board game excercise, been trying for 1 whole week and still can't finish this..:(

    here's what i've ended up with..when i was asked to enter the width and it must be even, and when i tried to run it, it would not do the looping.. please kindly help me.
    and i really don't know how to have output that says you have 10 chances to guess
    import java.util.*;
    import java.io.*;
     
    public class MemoryBoardGame {
    	public static void main(String[] args){
    	Scanner in = new Scanner(System.in);
    	int countLebar = 0 ;
    	int countPanjang= 0 ;
    	int cont = 0 ;
     
    do{
    		System.out.println("|-----------------------------------------|");
    		System.out.println("|                                         |");
    		System.out.println("|     Welcome to Memory Board Game        |");
    		System.out.println("|                                         |");
    		System.out.println("|                                         |");
    		System.out.println("|-----------------------------------------|");
    		System.out.print("Enter the length: ");
    		countPanjang = in.nextInt();
     
    	do{
    		System.out.print("Enter the width : ");
    		countLebar = in.nextInt();
    		if(countLebar % 2 != 0)
    		System.out.println("Sorry, the width must be an even number, please enter again:");
    	}while(countPanjang % 2 != 0);
     
    //making the array
    int[]Panjang = new int [countPanjang];
    int[]Lebar= new int [countLebar];
     
    int [][]number = new int [100][100];
    int baris, kolom;
    int i,j;
    int [][]random2 = new int [100][100];
    Random random1 = new Random();
     
    int cek[]= new int[100];
     
    	for(i=0;i<countLebar;i++){
    	for(j=0;j<countPanjang;j++){
    			int tempRandom;
    //formula width and length
    			do{
    				tempRandom = random1.nextInt(countPanjang*countLebar/2);
    				if (cek[tempRandom]<2){
    					cek[tempRandom]++;
    					random2[i][j]=tempRandom;
    					break;
    				}
    	}while(cek[tempRandom]>=2);
    }
    }
    	for(i=0;i<countLebar;i++){
    	for(j=0;j<countPanjang;j++){
    			System.out.print(random2[i][j] + " ");
    		}
    		System.out.println();
    	}
    	System.out.println();
     
    	int count=0;
    	int win=0;
    	boolean map [][] = new boolean[100][100];
     
    	do {
     
    		for(i=0;i<countLebar;i++){
    			for(j=0;j<countPanjang;j++){
    				if (map[i][j])
    					System.out.print(random2[i][j] + " ");
    				else
    					System.out.print("x");
    			}
    			System.out.println();
    }
     
    		System.out.println("1st Answer: ");
    		int x = in.nextInt();
    		int y = in.nextInt();
     
    //make the x
    		for(i=0;i<countLebar;i++){
    			for(j=0;j<countPanjang;j++){
    				if (x == j && y == i || map[i][j])
    					System.out.print(random2[i][j] + " |" );
    				else
    					System.out.print("X" );
    			}
    			System.out.println();
    		}
     
    		in.nextLine();
    		System.out.println("2nd Answer: ");
    		int p = in.nextInt();
    		int q = in.nextInt();
     
    		for(i=0;i<countLebar;i++){
    			for(j=0;j<countPanjang;j++){
    				System.out.print(x == j && y == i || q == i && p == j || map[i][j]   ? random2[i][j] + " " : "X ");
    				}
    			System.out.println();
     
    }
    System.out.println();
     
    		if (random2[y][x]==random2[q][p])
    			map[y][x]=map[q][p]=true;
    		count++;
     
    		for(i=0;i<countLebar;i++){
    			for(j=0;j<countPanjang;j++){
    				if (map[i][j])
    					win++;
    				else
    					win=0;
    			}
     
    }
    		if(win==countLebar*countPanjang){
    			System.out.println("Congratulation you win!!");
    			System.out.println("Score : " + (10-count)* countLebar * countPanjang * 10);
    			break;
    		}
    		in.nextLine();
    	}while(count<10);
     
    	if (count==10)
    		System.out.println("Sorry you lose:(");
    	in.nextLine();
    	System.out.println("do you want to keep playing?? \n1.Yes \n2.No" );
    	 cont = in.nextInt();
     
    }while(cont == 1);
    }
    }
    Last edited by jps; May 27th, 2013 at 11:41 AM. Reason: added code tags

  6. #6
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Please help with my new memory board game excercise, been trying for 1 whole week and still can't finish this..:(

    use printlns to print out the values of the variables that control the loops. Perhaps the variables hold unexpected values, or perhaps the wrong variables are being used to control the loops.
    Printlns should help locate the cause of the symptoms

Similar Threads

  1. Please Help Finish Project Memory Matching Game
    By Hernanhe1 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 25th, 2013, 01:13 PM
  2. Help with assignment about a board game (enum and array question)
    By Kranti1992 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 12th, 2012, 07:47 AM
  3. Java TV Board Game/Grid + Moving objects
    By Massaslayer in forum Java Theory & Questions
    Replies: 6
    Last Post: December 13th, 2011, 08:03 AM
  4. help with board game assignment
    By pjay in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 19th, 2011, 12:58 PM
  5. DOS board game
    By SageNTitled in forum Java Theory & Questions
    Replies: 5
    Last Post: March 4th, 2010, 03:53 PM