11 Posted Topics
Hey guys, I'm working on a project to use Huffman trees to compress a text file into binary. For instance, based on the frequency of the characters in a string like "aardvark", a - 3 r - 2 d - 1 v - 1 k - 1, compression using a … | |
Hey, I'm new to Python and wondering about the following bit of code. It tells me that the module random has no attribute randint. I've looked at the documentation and such and I think I'm doing it correctly, but obviously something's wrong. Any ideas? Thanks! [code] import random int1=random.randint(1, 6) … | |
I am creating a game in which I import images from files to represent characters, etc. I have created a class called Contents which represents anything that can be placed on a tile of the gameboard. A subclass of Contents (by several levels) is Wizard, to create a wizard character. … | |
Re: Not sure exactly how your reader program is set up, but you could have it read char by char and when it encounters a space (' ') you could instead set the char equal to 0 ('0'). So, [CODE] char readChar; //The character read by the reader if(readChar==' ') readChar='0'; … | |
Re: I'm using Netbeans's GUI builder, which has a similar setup to it. I think that means that JFrameBuilder expects a method called initiateComponent() where you add anything the frame contains (panels, buttons, text fields, event listeners, etc.) and set their properties and such. This method would then be called in … | |
I am working my way through an online book--Intro to Java Programming by David Eck--and in it he says that it is generally considered bad style to use the getGraphics() method to draw outside of a component's paintComponent method. Does anyone know why this is? | |
I'm making a JPanel for a game. I want the background to be an imported image, so I set up a ClassLoader to import the image and converted that to a URL. However, that URL appears to be null, as when I try to put the panel into a JFrame, … | |
Re: So to clarify... (hopefully) The '==' operator is only used with primitive variable types--int, double, boolean, etc. Strings are a type of Object; they did not "come with the system" but rather first had to be programmed in Java to define their behavior. For most objects obj, the .equals(obj) method … | |
So to get practice writing applets, I tried to write one that simply draws a chessboard in a 160 x 160 window. I am pretty sure I got the code right for both the html and java files, and I have the html file in the same directory as my … | |
Ok, so I'm trying to make a constructor for a text-based game for a monster. Here is the code for it: [CODE]public class Methods { String name; //characteristics of monsters int bodyPoints, mindPoints, attack, defense; public Monster(String name, int bodyPoints, int mindPoints, int attack, int defense) { this.name=name; this.bodyPoints=bodyPoints; this.mindPoints=mindPoints; … | |
Hey, so I'm trying to make a text-based game using mostly Swing GUI; the code I have so far is below. When I use JOptionPanes I modify the icon, title, and suchlike on them, so I have about two lines of code for every JOptionPane. I created methods for them … |
The End.