2,827 Posted Topics
Re: What happens if you generate a number greater than 13? [code] string getcard(){ int c; c=(1+ rand() % ([COLOR="Red"]52[/COLOR])); switch(c){ case 1: return "Ace"; break; case 2: return "Two"; break; case 3: return "Three"; break; case 4: return "Four"; break; case 5: return "Five"; break; case 6: return "Six"; break; … | |
Re: [url]http://www.derekscswebsite.com/RandomMazeJava/index.html[/url] [url]http://www.derekscswebsite.com/Javascript/Maze/index.html[/url] [url]http://www.derekscswebsite.com/Algorithms/RandomMaze/RandomMaze.html[/url] The above are links to a random maze creation program I created, as well as a detailed explanation of the algorithm I used. It's one way to make a maze. It's not the only way. | |
Re: [code=JAVA] public class FrogCalculator { private Frog operand1Frog; private Frog operand2Frog; private Frog unitsFrog; private Frog tensFrog; private OUColour colour; /** * Constructor for objects of class FrogCalculator */ public FrogCalculator() { Super(); } /* instance methods */ /** * Returns the receiver's operand1Frog */ public Frog getOperand1Frog() { return … | |
Re: [code] for ( ; [COLOR="Red"]*aPtr != '\0'[/COLOR]; aPtr++ ) [/code] This isn't going to work. Your array is defined for twenty elements. Who knows what is stored in the memory locations beyond that? You can't assume anything. I would pass the function the address of the last element of the … | |
| |
Re: I think you should set up a 2-D array of random integers (2 rows, 50 columns) and store them as you generate them. Right now you are displaying them, but then they are gone, so you won't be able to display them later, nor will you be able to search … | |
Re: [QUOTE=theashman88;882125]Hi I'm working on a program that compares the users response to an answer like a quiz. At first I wasn't sure how to do this using cin because the answer was two words. Someone helped me out and showed me the getline command. The only problem is if i … | |
Re: [QUOTE=blahblah619;825066]Alright. I now have one loop and the program ends, but now it prints(still replacing each number): 10 90 80 70 60 50 40 30 20 10 (program ends) I don't know how to get rid of the zero's and print "Blast off!" Here's the code block I changed: From … | |
Re: Use the shift operators. [url]http://www.learncpp.com/cpp-tutorial/38-bitwise-operators/[/url] Multiplying by a factor of 2 is much easier than multiplying by 100. Here's a basic example of how to use shift operators. [code] #include <iostream> using namespace std; int main () { int a = 12; // a = 12 cout << a << … | |
Re: You shouldn't read in a square root or a cube. You CALCULATE the square root or the cube. Thus this is incorrect: [code] cout<<"Enter 10 numbers:"<<endl; for(int i=1;i>=10;i++) cin>>SQUARE_ROOTS [i]; [/code] Don't read in data into the SQUARE_ROOTS array. You shouldn't be reading numbers in from the user in this … | |
Re: [QUOTE=danilopena;880501]do u know how like the process is set up and how it works?[/QUOTE] [url]http://www.java-tips.org/java-se-tips/java.util/how-to-read-input-from-console.html[/url] [url]http://java.sun.com/javase/6/docs/api/java/util/Scanner.html[/url] | |
Re: This is very often an issue where you have an excess newline character in the input stream from an earlier cin statement. The cin statemnent doesn't consume that newline. getline sees the newline, takes it, and doesn't pause for input. You want to flush the input stream so that any … | |
Re: You would have to store the order or location someplace. Perhaps you are doing so in the [ICODE]cars[/ICODE] or [ICODE]array [/ICODE]arrays. Index 0 is the front car, index 1 is the 2nd to front car, index 2 the 3rd to front car, etc.? That's one way to do it. There … | |
Re: It's almost certainly a scoping issue or Java doesn't know which class to look in. Where is this line located (what class is it in and is it a global variable?)? [code] CurrentAccount userCurrentAccount = new CurrentAccount(); [/code] Is it in the same class as this code? [code] accnum = … | |
I have what I thought was a straightforward program. [code=Perl] #!/usr/bin/perl -w use strict; $a = 6; $b = 9; $c = 7; print $a . "\n"; print $b . "\n"; print $c . "\n"; [/code] I assumed this would display: [code] 6 9 7 [/code] and it does when … | |
Re: I don't see any calls to an ExtendDVD constructor, so perhaps there are no ExtendDVD obejcts to display since none are ever created? I see these objects of type DVD created here: [code] DVD[] dvd = new DVD[3]; dvd[0] = new DVD(1, "Knocked Up", 2, 17.99, "min100");// declares a new … | |
Re: Best guess is that you have a newline remaining in the input stream. getline sees that, takes it, and thus doesn't pause for input. You need to flush the input stream so there's nothing in it when the program reaches the getline statement. [url]http://www.daniweb.com/forums/thread90228.html[/url] | |
Re: [QUOTE=nishant52;878641]Thank you for the reply. But still my problem is not solved. I want a method of finding the shortest distance which does not consider all the nodes(1000+) in finding the path.[/QUOTE] You said you had already selected the method and that it was Dijkstra's Method. Also, how can you … | |
Re: [QUOTE=djdanjo82;877675] Basically I am trying to figure out how to change the variable name while in a loop. [/quote] Change the variable name of what? And why? [QUOTE=djdanjo82;877675] guiArray.get(n) = new Gui(this); [/QUOTE] You can't use get this way. I'm not sure what you are trying to do, but you … | |
Re: When you ask the user for data using[ICODE] cin >>[/ICODE], only the part up to the first white space (in this case the first word the user enters) will be stored in the variable. Use [ICODE]getline[/ICODE] instead of [ICODE]>>[/ICODE] in order to get a full line from the user. Also, … | |
Re: It seems you have a program that does some things correctly and other things incorrectly. You are reading in a CSV file and that is working fine? And you are trying to read data into a map and a list and that's sort of working, but not really? We don't … | |
Re: [QUOTE=vs.vaidyanathan;876473]I hav two points on the ground at different distances from me . I have the angle swept by my eyes in going from one point to the other. But a camera performs this action by first panning(moving horizontally ) and then tilting(vertical depression or elevation.) Is there a formula … | |
Re: This program does not compile for me. Below is the code for StartGame. [code=JAVA] import java.util.Scanner; public class StartGame { public void StartGame(String name, int r, int c) { Scanner input = new Scanner(System.in); Player player1 = new Player(); DungeonMaze dungeon = new DungeonMaze(); Cells[] cellArray = new Cells[r*c]; dungeon.populateGrid(r,c, … | |
Re: [code=JAVA] JButton j[] = new JButton[s.length]; for(int i=0;i<s.length;i++) j[i].setText(s[i]); [/code] Line 1 creates the ARRAY of JButtons. It does not create any new JButton objects, so in line 4, you are setting text for a JButton that doesn't exist and you get a null pointer exception. Create the individual JButtons … | |
Re: [QUOTE=tomata2;875823]thnx but i mint what can i do with the random class ?i'm a beginner btw ..[/QUOTE] You need a program redesign from the ground up, I think. You have multiple main classes. You have a call to a CarRan constructor that does not exist: [code] CarRan ob2 = new … | |
Re: [QUOTE=jayless;874983]Hello, I need to find the code in netbeans where the name is stored as shown in the Title bar of the program and the taskbar of windows. Any ideas where to find that? ive been looking and searching for days now. I want to edit "Openbravo POS - 2.30beta" … | |
Re: I'm a little hazy at the game of life, but can you expand on the idea of why you need the buffer of 2 in the arrays (i.e. 42 x 42 array instead of a 40 x 40)? Are those edge and corner cells used in the game or are … | |
Re: How about storing all of the rectangles, not just the current rectangle, and painting them all on the image (not sure you really want to use an image rather than drawing the rectangles directly onto the applet. Does it really reduce flickering?), rather than just painting the current one? You … | |
Re: [QUOTE=Dendei;870754]Hi me and my class are getting this problem with tim.start(); and stop. we get start to work with a button but cant stop and we can stop with the keyboard but not with the buttons bad explaination i know but have an look plz :P [/QUOTE] Yes, I think … | |
Re: Try it out without making it official for a while. Say it's your nickname or something. Just say "Hi, I'm Julian", then in the rare cases where someone asks questions, say that it's a nickname and you prefer to go by that. Most people will respect that. If after doing … | |
Re: You have a sort and you have your GUI. These should be completely independent of each other. The sort itself should have nothing to do with the GUI. When you write a bubble sort function, it either is correct or it isn't and it has nothing to do with whether … | |
Re: Try changing: [code] car, car1 (1999, Honda); [/code] to [code] car car1 (1999, "Honda"); [/code] There should be no comma between the variable's type and the variable's name. Strings should be surrounded by quotes. | |
Re: [code] for (int i=0; i<nums.length; i++){ int digit = Integer.valueOf(nums[i]); count[digit]++; } [/code] digit is not a good name for this variable in my opinion since it can range from 0 to 999, not 0 to 9. [code] int highIndex = 0; for (int i=0; i<10; i++) { if (count[i] … | |
Re: [QUOTE=Punkis448;599360] [code] #include <stdio.h> #include <stdlib.h> [/code] any helpful tips or if you find any mistakes...please tell me[/QUOTE] Is this C or C++? Those like like C headers and a lot of your code looks like C code. If it's C++, you should probably change headers and some of the … | |
Re: For sure, don't generate every permutation. I am wondering if a hash function could be useful for this. Don't generate any permutations. Get a good hash function for the scrambled words. A hash function that could certainly be improved upon would be this: a= 0, z = 25, add the … ![]() | |
Re: [QUOTE=TaubBaer;867017]How do I solve this problem?[/QUOTE] Use a constructor that DOES exist or import the class. In your case, it's the former. Here are your constructors: [code] public PoliceOfficer() public PoliceOfficer(String on, int bn, ParkedCar pc, ParkingMeter pm, ParkingTicket ticket) public PoliceOfficer(PoliceOfficer original) [/code] Here's your error: [quote] MeterTest.java:19: cannot … | |
Re: Keep in mind that this line (see red part): [code] std::cout << "\n" << (*n) << " " << [COLOR="Red"](*n+1)[/COLOR]; [/code] displays[ICODE] aObj.arr[0] + 1[/ICODE] , not [ICODE]aObj.arr[1][/ICODE]. In your case, they are the same, but if you change line 23 to equal something other than 2, you'll still get … | |
Re: [QUOTE=frosty1979;866271]no i did not find anythink what can help me out[/QUOTE] I think Sky Diploma is suggesting that you close THIS thread and post a new thread on THAT forum. | |
Re: Here's your getInput function from your superclass: [code] private Wire Input; /* code */ public Wire getInput() { return Input; } [/code] Here's your function call from the NotGate class. [code] if( super.getInput() ) // HOW TO COMPARE!!! { }[/code] getInput returns an object of type Wire. You are comparing … | |
Re: [url]http://java.sun.com/products/jfc/tsc/articles/timer/[/url] [url]http://javaboutique.internet.com/JavaTimer/[/url] [url]http://java.sun.com/javase/6/docs/api/javax/swing/Timer.html[/url] [url]http://java.sun.com/javase/6/docs/api/java/util/Timer.html[/url] [url]http://www.javaeecoding.com/JavaUtil/Timer/Scheduler1.html[/url] | |
Re: [QUOTE=BestJewSinceJC;863789]True, it did start out like that, but what is the relevance of that? I'm just moving rectangles around, but when I move the rectangle, the old ones [I]were[/I] duplicating because the old ones never got 'erased'. I fixed that problem by using clearRect[/QUOTE] I generally have a class that … | |
Re: You lose all formatting when you copy and paste here. I don't know what Figure A and Figure B are. Are they images? Was there spacing in this post? You can use code tags to preserve Courier type spacing (all characters equal width) - Otherwise the spacing gets stripped out: … | |
Re: I'm a native English speaker and I've always used the two words interchangeably, as in "I am jealous that you have a nice car and I don't." Apparently I need to replace "jealous" with "envious". At any rate, jealousy/envy is good if it helps motivate you in a positive direction, … | |
Re: There's more than one way to do it and it may depend on the exact spec. I'm assuming it's like the NFL with the NFC versus the AFC or whatever. I like the idea of three separate vertical panels if this is the idea. The NFC team boxes are in … | |
Re: [QUOTE=NathanOliver;862993]i see where your going but i want to make sure that i have every possible uppercase and lowercase alphanumeric string you can have in the list. also i know that there are also the characters the normal characters on the keyboard and i have them in there because sometimes … | |
Re: [QUOTE=kingarabian;862080]This code is from a client. Runescape client. Its to big to post. Want me to post some specific stuff? I will if you want...[/QUOTE] I think the larger question (at least for me) is why are you trying to make sense of the decompiled code if you already have … | |
Here's one of those "wacky news" stories. Some guy named his kid Adolf Hitler because he liked the name and "because no one else in the world would have that name." (there's a good reason for this). His daughter is named "Aryan Nation", probably for similar reasons. Anyway, they threw … | |
Re: Note the revisions. There is still a lot for you to do, but this will at least compile. [code=JAVA] import java.awt.*; import javax.swing.*; public class Book { // Variables String Title; private int Price, Pages; // METHODS private String getTitle() { return Title; } private void setTitle (String title) { … | |
Re: [QUOTE=Ancient Dragon;826989]Look at the money [URL="http://golf.about.com/od/tigerwoods/p/tiger_woods.htm"]Tiger Woods[/URL] makes for just hitting his balls around the yard :)[/QUOTE] That at least takes skill. Is anyone any better than anyone else at Rock-Paper-Scissors? And did this event really happen or is it a well-crafted cut and paste of other footage? I can't … | |
Re: I don't think I understand. There is no myPanel class (presumably it extends JPanel and you haven't posted it). I see no difference between the two lines below other than the fact that the two classes have different names. There must be something in myPanel that is different from paintHang, … |
The End.