1,171 Posted Topics
Re: Where do you have problems with in specific? I'd suggest you to perform a Google search on 'Sokoban', look at existing implementations, play a couple of them and see how it works. Familiarize yourself with the rules of the game. Start coding, and when you encounter problems come back and … | |
Re: [Here](http://lmgtfy.com/?q=java) and [here](http://www.catb.org/esr/faqs/smart-questions.html). | |
Re: [Here](http://lmgtfy.com/?q=c%2B%2B), [here](http://www.daniweb.com/software-development/cpp/threads/78223/read-this-before-posting-a-question) and [here](http://www.catb.org/esr/faqs/smart-questions.html). | |
Re: Golden advice from a quick skim through your code: Line 122-123: **NEVER EVER** leave your catch blocks empty! **[1]** It will hide away every potential error and problem at the time one occurs. Whenever you feel tempted to leave a catch block empty, always at least insert a call to … | |
Re: You can use [filters and sorters](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#sorting) on a JTable, if all the data is already in your table model. | |
Re: Have you tried connecting to your database using the Netbeans Services tab? This should work before you proceed. | |
Re: Open your file in append mode: PrintWriter output = new PrintWriter(new BufferedWriter(new FileWriter(file, true))); | |
Re: > My problem is with the constructor: where does it get called? I would have thought in this line > Player player; but shouldn't this be Player player = new Player();? You are right in saying that the line `Player player;` does not call the constructor, however, if you look … | |
Re: Implement your own table model as described in: http://docs.oracle.com/javase/tutorial/uiswing/components/table.html http://www.informit.com/articles/article.aspx?p=332278 | |
Re: Implement your own [AbstractTableModel](http://docs.oracle.com/javase/6/docs/api/javax/swing/table/AbstractTableModel.html) and let it interact with the database. You'll have to provide your own remove method there, and make use of the fireTableRowsDeleted method to notify the JTable that a row was deleted. Here are two links that should provide you with the information you need (including … | |
Re: >The error I am getting from this is, "Non-static variable panel, cannot be referenced from a static context". Let's analyze what the compiler is trying to tell us: * **Non-static variable panel**, let's see... variable panel is declared on line 7, and there's no static keyword there, so it is … | |
Re: > For re-usability it would be better to return the long value, rather than set a fixed named variable that's declared elsewhere? In addition it would be a good idea then to also rename the method to `getUniqueIdentifier()`. | |
Re: >how do i get a1 as in its control name in swing and not the actual string http://stackoverflow.com/questions/4958600/get-a-swing-component-by-name You could also put the components that represent your board squares in an array and translate the input from your textfield to the corresponding array index. | |
Re: 1. Your attribute declarations (lines 14-23) should be outside any method (now they are in your main method, move them out). 2. You've put your applet() method (lines 28-43) inside your main method, move it outside of your main. 3. You miss a curly ending brace for your main and … | |
Re: Probably because the intent is to write your own answer. | |
Re: Line 45 in the code you posted: `public static Void Main(String[]args)` correct it to: `public static void main(String[]args)` (`main` without capital and `void` without capital) (Even though it will compile with `Main` as identifier, it won't run because there's no `main` defined) | |
Re: First off, **if you don't need the synchronization** provided by a [StringBuffer](http://docs.oracle.com/javase/6/docs/api/java/lang/StringBuffer.html), then prefer using a [StringBuilder](http://docs.oracle.com/javase/6/docs/api/java/lang/StringBuilder.html). Here's what the Java API states about StringBuilder: *This class provides an API compatible with StringBuffer, but with no guarantee of synchronization. This class is designed for use as a drop-in replacement for … | |
Re: >how do I draw that exact apple tree i specified in my txt file? What exactly did you do in your AppleTree's paint method? >Should I put them in a Map here? Nope. >public String color; >public int ID; Change to private and make getter methods for these. In your … | |
Re: He better learns [this](http://www.catb.org/esr/faqs/smart-questions.html) first. | |
Re: >CAN ANYBODY PLEASE TELL HOW TO LEARN C++ Coding Read books, write alot of code, be prepared to fail alot... >IS THAT THEROY IMPORTANT Pretty much. >PLEASE HELP ME TO MAKE MY CARRIR . . . MY AIM IS TO BECOME A SOFTWARE ENGINEER Read books, write alot of code, … | |
Re: >i want to read the data from text file and write to excel file. You'll need to be more specific on how the data is formatted in these files, perhaps include an example of how your text file looks, and how your "excel file" should look. | |
Re: Take a look at: http://www.homeandlearn.co.uk/java/java_formatted_strings.html . Use `String.format()` instead of `System.out.printf()`. | |
Re: Try a [GridLayout](http://docs.oracle.com/javase/6/docs/api/java/awt/GridLayout.html). FYI: It is also possible to do this entirely without buttons, it would be more complicated though (since you'd need to compute the clicked square from the coordinates of the mouse click). | |
Re: You should be more specific as to what you want to do with your truncated number. Do you want to put it in a `String`? Do you want to print it to the screen and keep the exact value in your variable? Do you want to truncate the result in … | |
![]() | Re: [Read this first](http://www.catb.org/esr/faqs/smart-questions.html). Have fun with it ;-) |
Re: >does not move past the accept method In fact it does move past the accept method. The reason why your "Client connected" message is not displayed is because you add it to a `String`, but you don't append it to your `JTextArea`. >What could be creating the problem that I … | |
Re: currentRoom = room; Room currentRoom = new Room(); // here is the problem Why creating a new room there, can't you just use the one passed to the constructor? Also, could you clarify the following, not sure if I understand it: > My problem is that Character is an Abstract … | |
Re: > couldnt figure out why the output line always appears twice! like: > you have added computer to your inventory > you have added computer to your inventory My first guess would be the following code from `takeItem()`: playerInventory.addItemToInventory(itemToBePicked); // line 16 if (playerInventory.addItemToInventory(itemToBePicked)) // line 17 Notice that `addItemToInventory()` … | |
Re: The HashMap is a good suggestion, although I want to add something to it. Personally I wouldn't recommend putting an Integer in it, since Integer is immutable, and you'll have to issue a `put()` everytime you want to update the count. I suggest you create a Counter class that wraps … | |
Re: **@fallen21468:** In addition for when you get more experience with Java, you might want to keep this link bookmarked: http://stackoverflow.com/questions/9554636/the-use-of-multiple-jframes-good-bad-practice | |
Re: > Hello ... I think all of these are O(n) That's not true, take a look at (B) and (D), where the index is divided by / multiplied by two. These are O(log(n)). This is O(n): int index = 1; while (index < n) { ... index++ // index is … | |
Re: This might be of interest too: http://joda-time.sourceforge.net/ . | |
Re: `while(plaintext.length() > 0)` Strings are immutable, and the reference is never set to anything else. This has the potential to cause an infinite loop. The reason why it doesn't at runtime is because you keep incrementing `counter`, and accessing characters from that String by invoking `plaintext.charAt(counter)`, eventually it will lead … | |
Re: Create an array which holds the board state. (don't forget to initialize the board before using it) 1) Write code to display the board (from the array). (Test whether everything is displayed correctly). 2) Write code to accept user input. 3) Write code which processes the user input, and places … | |
Re: > Please wrap your code in code-tags the next time you post any code. > Whew! That's a lot of errors: > RollingDice.java:12: ';' expected > public static void main (String[] args ) > ^ > RollingDice.java:16: <identifier> expected > die1 = new Die() ; > ^ > RollingDice.java:17: <identifier> … | |
A program which displays the prime factors of a given number, all the 'hard' work is done by the [B]factorize()[/B] function: [CODE=c] /* Find out the prime factors * of a given number and print * them on the screen */ void factorize(int n) { int d = 2; if(n … | |
Re: Pointers are often used in combination with dynamic memory allocation ... Lets say you want to create a table of objects, but it depends on the situation where the program is in, you would rather use a pointer to a table of objects (dynamic memory allocation) ... But when you're … | |
Re: Assert is a C++ macro and when the compiler comes across assert, it replaces the assert call with the instructions to evaluate an expression + the instructions to exit the program if the expression returned false ... e.g.:[ICODE]assert(1>2);[/ICODE] will exit the program because 1 isn't greater than 2 ... | |
This is how mine [B]strcmp[/B] function would look like if I'd to implement it from scratch :) | |
Re: Could you post your program's source code as well? | |
Re: [QUOTE=revenge2;895494]hello there. i've installed mingw compiler and im wondering how i would go about setting up notepad++ to compile my c/c++ code?. How do i do this? -regards.[/QUOTE] I assume that the [B]g++[/B] command is in your PATH and that your environment variables are set correctly. Then follow these steps: … | |
I've written a program to add two hexadecimal numbers ... Njoy ! tux4life | |
Re: [B]>>i found it from a book.[/B] [B]>>is it cheating to learn from any body who knows well?[/B] I don't believe that code comes from a book. If that person ``who knows well' writes such code, full with magic numbers, and no comments at all - just to give a few … | |
Re: Firefox, because of it's broad support for plugins :) | |
Re: Ever heard of "Google" the mighty search machine? Let me introduce you to what you can find with it: [url]http://stackoverflow.com/questions/142016/c-c-structure-offset[/url] | |
I've written a C++ function which converts an integer to a (C++-)string ... [CODE=C++] ... string s = itos(5698); cout << s << endl; /* Will print '5698' on the screen */ ... [/CODE] You MAY use this code for anything you want but [B][COLOR="Red"]you aren't allowed to sell this … | |
Re: It's apparently a heat problem ... Consider installing some extra coolers into your computer ... You'll also have to remove that exploit from your computer ... Maybe you should also try using another antispyware like Spybot S&D or Ad-aware Free ? | |
Re: [QUOTE=HelloMe;1507546]ups the brackets again "[" code "]" here your code "[" /code "]" like i said, the brackets without quotations :)[/QUOTE] You can use the [I][B]noparse tag[/B][/I]([ICODE][noparse][noparse][/noparse][/noparse][/ICODE]) to make it more clear. [B]Writing:[/B] [noparse][noparse] [code] // Your code here [/code] [/noparse][/noparse] [B]Will yield:[/B] [noparse][code] // Your code here [/code] [/noparse] | |
Re: [QUOTE=programing;1507704] i am read java how to program are you know other good books .? >[/QUOTE] Read the ``[URL="http://www.daniweb.com/software-development/java/threads/99132"]Starting Java[/URL]' sticky thread, it contains plenty of useful resources for every programmer learning or using Java. |
The End.