Page 3 of 3 FirstFirst 123
Results 41 to 58 of 58
  1. #41
    poisson is offline Member
    Join Date
    May 2010
    Location
    Singapore
    Posts
    31
    Rep Power
    0

    Exclamation This is the error when i entered the same codes which worked and I posted here ...

    This is the error when i entered the same codes which worked and I posted here ...

    Java Code:
    import java.util.Scanner;
    import java.util.Random;
    public class thePrettyReckless {
    
    	public static void main(String[] args) {
    //[=====================[INTRODUCTION PANEL]========================================================]
    		System.out.println(" Welcome to the word game!!!");
    //[==================================================================================================]
    //[=====================[INITIALISE RANDOM]==========================================================]
    		Random randi = new Random();
    		Scanner scan = new Scanner(System.in);
    //[==================================================================================================]
    
    //[=====================[CHECKS LETTERS FOR ITS EXISTENCE IN THE "WORDS.TXT"]========================]	
    		String wordLog[] = FileUtil.readDictFromFile("words.txt");
    //[==================================================================================================]
    //[=====================[ARRAY FOR LETTERS, ARRAY FOR ASSIGNED LETTER SCORE AND VOWELS]==============]
    		char [] alphaArray = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    		int [] alphaScore = {1,3,3,2,1,4,2,4,1,8,5,1,3,1,1,3,10,1,1,1,1,4,4,8,4,10};
    		char[] Vowels = {'a', 'e', 'i', 'o', 'u'}; 
    		//This is to assign the letters and place it within numbers of 10 ===========================]
    		char[] shuffleLetter = new char[10];
    		int[] blender = new int[31];
    		//Initialise playerName input
    		String playerName = null;
    		//Initialise index/position
    		int index;
    //[=====================[PRINTS OUT "FINDYOURLETTERS" AND "LETTERS FOR PLAYER"]======================]
    			System.out.println("FindYourLetters");
    			//Player will be able to enter their name to be refer as in the game=====================]
    			System.out.print("Enter your name: ");
    			playerName = scan.nextLine();
    			//Prints out statement "Letters for{the name the player entered earlier}:"===============]
    			System.out.print("Letters for " + (playerName) +": ");
    //[==================================================================================================]
    //[=====================[POOL OF 10 RANDOM LETTERS!!!]===============================================]
    			//Ensure that there are at least 2 vowels in the generated words
    			for (int k = 0; k < 2; k++){
    			index = randi.nextInt(Vowels.length);
    			shuffleLetter[k] = Vowels[index];
    		}
    			
    		//This would produce the ten random letters it's supposed to
    		//This is to initialise "i" and i is less than the length of shuffleLetter and the iterator
    		for (int i = 0; i < shuffleLetter.length; i++) 
    			{
    			int xx = randi.nextInt(alphaArray.length); 
    			//Check whether the above code works 
    			if (shuffleLetter[i] == '\u0000')
    			{
    				shuffleLetter[i] = alphaArray[xx];
    			}
    			//This would print out the letters and I added the function 
    			//Whereby the comma would be printed out for every letter
    			//until the last letter where there would not be any comma
    			System.out.print(shuffleLetter[i]+ ((i < 9) ? ", " : " " ));
    			}
    //[==================================================================================================]
    //[=====================[PASS OR QUIT - PLAYER'S CHOICE]=============================================]
    		System.out.println("");
    		System.out.println("Enter your word (or $ to pass or # to quit): ");
    //[==================================================================================================]
    		}
    	}
    Here's the screenshot :



    I'm using Java Eclipse and I do not know what's going on ...

    It worked last Monday ... and my presentation is a day away ... so I'm really nervous .... >.< :(:(:(:(:(
    Last edited by poisson; 06-21-2010 at 08:56 AM.

  2. #42
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default

    Sorry, I don't use your IDE.
    Can you open a command prompt in the folder with the class files and enter the java command: java AndrewFindYourLettersGame
    Also do a dir command to show what is in the directory.
    Copy and paste the full contents of the console here.

    Is the class in a package?

  3. #43
    poisson is offline Member
    Join Date
    May 2010
    Location
    Singapore
    Posts
    31
    Rep Power
    0

    Exclamation Reply to Norm ..

    AndrewFindYourLettersGame :



    Directory of my C drive :



    Directory of my C:\OOP\WORKSPACE\



    Directory of my C:\OOP\WORKSPACE\Java Ass 001\src\


    ================================================== =====
    This is the classes I've created but have not link with the "AndrewFindYourLettersGame.java" yet.

    The codes for public Class GameRulez.java:

    Java Code:
    public class GameRulez extends AndrewFindYourLettersGame
    {
    	private String GameRulez;
    	
    	[COLOR="Blue"]//Constructor[/COLOR]
    	GameRulez(String Instructions) 
    	{
    		this.GameRulez = Instructions;
    	}
    	
    	void GameRulez(String Instructions)
    		{
    			System.out.println("*Each player are to form a word with 10 random letters given to them\n");
    			System.out.println("*If the first player types in an invalid word, he/she can try again OR" + 
    					           "be given the option to pass or quit\n");
    			System.out.println("*If the first player decides to pass, the total score for word and player" + 
    					           "will be shown,\n");
    			System.out.println("and it will be Player 2's turn\n");
    			System.out.println("*If the Player 1 types in a valid word, the total score will be shown and" + 
    					           "it will be Player 2's turn, vice versa\n");
    			System.out.println("*When any player decides to quit the game," + 
    					           "the score will sum up and both players' scores will be shown.\n");
    			System.out.println("*If player 1 score is higher than Player 2's, he will be declared winner\n");
    			System.out.println("*However, if both players have the same score, it will be a draw.\n");
    		}
    		[COLOR="Blue"]//Set the GameRulez[/COLOR]
    		void setGameRulez(String Instructions) 
    		{
    			this.GameRulez = Instructions;
    		}
    
    		[COLOR="Blue"]//return the welcomeMessage[/COLOR]
    		String getGameRulez() 
    		{
    			return GameRulez;
    		}
    	}[COLOR="Blue"]//End[/COLOR]
    The code for public Class Welcome:

    Java Code:
    public class Welcome extends AndrewFindYourLettersGame
    {
    	[COLOR="Blue"]//Initialise welcomeMessage which will be printed out as a string
    	//Private is used instead so that only the member of its class can accessed it[/COLOR]
    	private String welcomeMessage;
    	
    	[COLOR="Blue"]//Constructor[/COLOR]
    	Welcome(String IntroMessage) 
    	{
    		this.welcomeMessage = IntroMessage;
    	}
    	void welcomeMessage(String IntroMessage)
    	{
    		System.out.println("Welcome to the FindYourLetters Game!!!");
    	}
    	
    	//Set the welcomeMessage
    	void setWelcomeMessage(String IntroMessage) 
    	{
    		this.welcomeMessage = IntroMessage;
    	}
    
    	
    	 
    	//return the welcomeMessage
    	String getWelcomeMessage() 
    	{
    		return welcomeMessage;
    	}
    }[COLOR="Blue"]//End[/COLOR]
    Is there something wrong with my project build-path configuration or something ...

  4. #44
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default

    From your screen prints I see that there is NOT a AndrewFindYourLettersGame.class file in the /src folder.
    When you enter: java AndrewFindYourLettersGame
    the java program looks to read the AndrewFindYourLettersGame.class file.
    When it doesn't find it, it gives the error message: NoClassDefFoundError

    Where is/are the class file(s)? That is the folder you should be in when you enter the java command.

  5. #45
    poisson is offline Member
    Join Date
    May 2010
    Location
    Singapore
    Posts
    31
    Rep Power
    0

    Exclamation Classfile?

    Classfile? as in?

    :confused:

  6. #46
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by poisson View Post
    Classfile? as in?
    Compiled Java source code stored in a file with the extension .class.

    kind regards,

    Jos

  7. #47
    poisson is offline Member
    Join Date
    May 2010
    Location
    Singapore
    Posts
    31
    Rep Power
    0

    Unhappy My codes have no automatic creation of .class files ...

    Quote Originally Posted by JosAH View Post
    Compiled Java source code stored in a file with the extension .class.
    But when i look inside the "bin" folder where all the .class file are supposed to be stored, it's empty ... ><

    So how do i create those .class files for my codes as it didn't come with it, sooo...

    Does that mean I'll have to start all over again and re-write codes, but how do i ensure or know whether or not , the .class files are being created when i write my programs?

  8. #48
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by poisson View Post
    But when i look inside the "bin" folder where all the .class file are supposed to be stored, it's empty ... ><

    So how do i create those .class files for my codes as it didn't come with it, sooo...

    Does that mean I'll have to start all over again and re-write codes, but how do i ensure or know whether or not , the .class files are being created when i write my programs?
    That's what your JVM was complaining about: it couldn't find the class file; did you notice the little red square with the white diagonal cross in it? That means there are errors in your project, most likely compilation errors; fix those first and see if class files are generated by the compiler. There is no need to start all over again.

    kind regards,

    Jos

  9. #49
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default

    Aren't IDEs wonderful for beginning students. Its all magic. They have no idea of what is going on. Any problem and they're lost.

  10. #50
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Norm View Post
    Aren't IDEs wonderful for beginning students. Its all magic. They have no idea of what is going on. Any problem and they're lost.
    It's worse than that: they don't read and won't even notice the error signals/icons shown by their IDE; when it doesn't work the way they had in mind they go: "duh, it must be a Java bug, should I edit the registry? Install a new Java? Buy a larger monitor? A bigger disk? Another computer? My teacher sucks! And this forum sucks big times!".

    kind regards,

    Jos ;-)

  11. #51
    poisson is offline Member
    Join Date
    May 2010
    Location
    Singapore
    Posts
    31
    Rep Power
    0

    Angry I do not "Not like" this forum big times dude!

    Ok, thanks to Senior Norm and JosAH, I did checked my codes and edit some stuffs, so now it's working again, so it was my bet.

    And this forum doesn't suck big times, it did help me when i browse through others solutions and problems putting me in the right track, and this forum only sucks when people start talking like this :
    when it doesn't work the way they had in mind they go: "duh, it must be a Java bug, should I edit the registry? Install a new Java? Buy a larger monitor? A bigger disk? Another computer? My teacher sucks! And this forum sucks big times!".
    :mad:

    Isn't it common for me newbies to think like that?

    i admit it was my bet, my codes were messed up and i did noticed the errors and signals :
    It's worse than that: they don't read and won't even notice the error signals/icons shown by their IDE;
    :)
    =
    just didn't know what it meant, it's profound to me, I read some books in the library , asked my classmates and searched it up the internet before coming to this forum where i know there are people who encountered this problem or heard of this problem before or even the pros...

    But thanks anyway!! :):):)

  12. #52
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    @ josAH

    I respect your knowledge anybody who reads these forums must do, but you must know the person asking the question, there is no denying your charArray method here, but as I said before this person is a beginner to programming, throwing out pre defined functions will help him get it done, but his knowledge of why it worked will be zero, which is not helpful, sometimes you have to take a step back from your expertise, which you have in abundance no doubt, and get very basic, which is more beneficial in his development in the long run. That is not to say your input was useless, I for one thing never studied fortran or pascal had no idea that this was their style( but I certainly knew it was long winded compared to what java can do) , I would have done a charArray too, but I wanted to show the lad something behind a method that is all.
    Last edited by al_Marshy_1981; 06-25-2010 at 12:49 AM.

  13. #53
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    @ poission

    I have told you twice atleast in this thread not to go too far ahead of yourself when making a program.

    Listen, a man wants to make a house, he does not go barging in with concrete, wood, enthusiasm etc, he plans....

    same goes for programming, as far as I am concerned you are still just after understanding how to get the alphabet sorted everything after is a shot in the dark. no real engineer works this way, and since you decided to be a programmer you are now an engineer so start making plans, 2 pages ago I asked you now that you have the alphabet, how do you put scores to each letter? where is the program (ON ITS OWN THAT DOES THIS) when it works on its own then integrate it with the rest of your program.

    And if difficulties come back and ask more questions.

  14. #54
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,651
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by al_Marshy_1981 View Post
    @ josAH

    I respect your knowledge anybody who reads these forums must do, but you must know the person asking the question, there is no denying your charArray method here, but as I said before this person is a beginner to programming, throwing out pre defined functions will help him get it done, but his knowledge of why it worked will be zero, which is not helpful, sometimes you have to take a step back from your expertise, which you have in abundance no doubt, and get very basic, which is more beneficial in his development in the long run. That is not to say your input was useless, I for one thing never studied fortran or pascal had no idea that this was their style( but I certainly knew it was long winded compared to what java can do) , I would have done a charArray too, but I wanted to show the lad something behind a method that is all.
    I beg to differ: your code will probably be copied/pasted verbatim without further understanding (the array manipulation is the tricky part in the code). My code suggestion can't be turned in as is: the OP has to read the API documentation for it to at least partially understand it. And why not show beginners how to do things the good way from the start?

    kind regards,

    Jos

  15. #55
    poisson is offline Member
    Join Date
    May 2010
    Location
    Singapore
    Posts
    31
    Rep Power
    0

    Question Assigning the scores to the letters?

    al_Marshy_1981, this is on its own whereby the scores are assigned to each letters in the letters array...

    Java Code:
    char [] letters = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    
    letters [0] = 1
    letters [1] = 3 
    letters [2] = 3
    letters [3] = 2
    letters [4] = 1
    letters [5] = 4
    letters [6] = 2
    letters [7] = 4
    letters [8] = 1
    letters [9] = 8
    letters [10] = 5
    letters [11] = 1
    letters [12] = 3
    letters [13] = 1
    letters [14] = 1
    letters [15] = 3
    letters [16] = 10
    letters [17] = 1
    letters [18] = 1
    letters [19] = 1
    letters [20] = 1
    letters [21] = 4
    letters [22] = 4
    letters [23] = 8
    letters [24] = 4
    letters [25] = 10

  16. #56
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,562
    Rep Power
    25

    Default

    What is the purpose of the code you just posted?
    You define an array and initialize it with chars then immediately change the array's contents to numbers???

  17. #57
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    Quote Originally Posted by Norm View Post
    array's contents to numbers???
    Would've expected some kind of warning at least :eek: poisson, perhaps a Map<Character,Integer> will help.

    [rant]
    Quote Originally Posted by Josah
    It's worse than that: they don't read and won't even notice the error signals/icons shown by their IDE; when it doesn't work the way they had in mind they go: "duh, it must be a Java bug, should I edit the registry? Install a new Java? Buy a larger monitor? A bigger disk? Another computer? My teacher sucks! And this forum sucks big times!".
    I should kick you for that, seeing as I started by using Eclipse, and never once figured it was a Java bug. And I'm self-taught. Makes me figure its not the beginners, its the people who don't really want to be programming.

    Java Code:
    Person JosAH = new Person("Josah");
    JosAH.kick();
    Hmm, shouldn't forget Norm's attack on us beginners with IDE's as well, but I'm too tired for a kick, so...
    Java Code:
    Person Norm = new Person("Norm");
    Norm.scold();
    [/rant]
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

  18. #58
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    Quote Originally Posted by poisson View Post
    al_Marshy_1981, this is on its own whereby the scores are assigned to each letters in the letters array...

    Java Code:
    char [] letters = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    
    letters [0] = 1
    letters [1] = 3 
    letters [2] = 3
    letters [3] = 2
    letters [4] = 1
    letters [5] = 4
    letters [6] = 2
    letters [7] = 4
    letters [8] = 1
    letters [9] = 8
    letters [10] = 5
    letters [11] = 1
    letters [12] = 3
    letters [13] = 1
    letters [14] = 1
    letters [15] = 3
    letters [16] = 10
    letters [17] = 1
    letters [18] = 1
    letters [19] = 1
    letters [20] = 1
    letters [21] = 4
    letters [22] = 4
    letters [23] = 8
    letters [24] = 4
    letters [25] = 10
    you have just made a char array (which will hold charcters e.g. 'a', 'b' etc why do you think this array can hold numbers?? Think more clearly you have an array of charcters how can you assign number values to them? Think very simply, do not go too far ahead, what in your opinion is the easiest way to get values assigned to each letter, post your reply and DO NOT be afraid to be wrong.

Page 3 of 3 FirstFirst 123

Similar Threads

  1. What are you using to write your code?
    By CaptainMorgan in forum New To Java
    Replies: 996
    Last Post: 09-27-2014, 02:32 AM
  2. How To Write Unmaintainable Code
    By tim in forum Forum Lobby
    Replies: 2
    Last Post: 02-07-2010, 09:19 PM
  3. Can I write code in 2 different files ?
    By fartek in forum New To Java
    Replies: 2
    Last Post: 02-14-2009, 03:48 PM
  4. Help me to write a secure code
    By Bhavis in forum Advanced Java
    Replies: 4
    Last Post: 01-21-2009, 06:06 AM
  5. How to write code comments
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 08:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •