2,040 Posted Topics
Re: Because you are trying to modify other people code and you completely have no idea at all. This is a bad start. What you need to do is to step back and look at the problem again. Now, [Monte Carlo method](en.wikipedia.org/wiki/Monte_Carlo) is used to estimate a value using randomized samples. … | |
Re: The problem is we do not know what the encoding algorithm used in the encryption. Your post implies that you know the algorithm and need only a key value between 0 to 255 in order to decrypt (decode) it. It seems that may be wrong. Anyway, to try to do … | |
Re: Line 58 & 59, what do you think the value that *nextInt()* method will return? Read its [API](http://docs.oracle.com/javase/6/docs/api/java/util/Random.html#nextInt()) and you will find out that the range of returned value (which will be between 0 to 2^32). It is obvious that it will be out of display range you are trying … | |
Re: It doesn't seem to break your block, but it may give you an unintentional result if you allow modification of the class without synchronize the process anywhere. You need to watch out for that when dealing with multiple threads. | |
Re: But it will break if I enter "a" instead of a number... :( | |
Re: Or are you talking about this [Raptor](http://raptor.martincarlisle.com/)? If so, maybe this [link](http://cgs1000spc.blogspot.com/2011/12/arrays-in-raptor.html) could explain how you access an array element in Raptor. | |
Re: scrager is correct on declaring a string on multiple lines. A string, however, can contain new line character, and that should not be confused with the multiple line span. //i.e. var test = "<p>rajnas asdjhsadnmdas dasjads jmsad dasndsaads bnas</p> <p>ahdndsa</p>"; // error var test = "<p>rajnas asdjhsadnmdas dasjads jmsad dasndsaads … | |
Re: 1)Are you talking about comparing 2 array elements, or 1 item with another array? If it is only 1 item with another array, you simply go through each element in the array and compare each item with the value you want to compare. If it is equal, do the iframe … | |
Re: At least you can see that the code syntax is valid and can be compiled & run? :) | |
Re: The reason is the [algorithm](http://en.wikipedia.org/wiki/AVL_tree) of node deletion. "If the node is a leaf or has only one child, remove it. Otherwise, replace it with either the largest in its left sub tree (in order predecessor) or the smallest in its right sub tree (in order successor), and remove that … | |
Re: In Producer class inside messageConsume() method, did a call from consumer go through the loop down to the checking for region? If so, did it actually get through inside the checking region if-condition? Try to print out each line of your process to pin point where exactly is wrong. Anyway, … | |
Re: Ah good ol' dragon book. :) That's what I used when I took compiler class. | |
Re: The problem is that the library is a hard-coded library which expects a certain type of object to be passed to the function without handling any invalid case. In JavaScript, there is no type checking, so you could pass any thing (including null or undefined) to the function. The function … | |
Re: OK, are you required to do it with 2 queues in the implementation? Are you allowed to use recursive methods instead? Does your queue class has a peek() method -- a method to look at the value of the last item in the queue and not dequeue the queue. Anyway, … | |
Re: I'm not looking at how it works, but I will give you some thought about what may happens.. 1)Line 13, do you know that a file name can contain most character (if not all)? For example, you could have a file name "abcd.efg.doc" especially on Windows. The way you extracting … | |
Re: @deepecstasy, there is no (visible) pointers in Java. There is NO need to manually deallocate memory in Java because the GC will automatically do it for you. Simply stop referring to the created object for a while, and the GC will wipe it out from the memory. If you comes … | |
Re: Here are steps if the node is in the middle of the list (not head or tail). 1)Update the point-to *next* node of its previous node to its *next* node. 2)Update the point-to *previous* node of its next node to its *previous* node. /* Assuming nodeX0 is the head. Removing … | |
Re: Not so sure what you want to do. Anyway, have you read this [Matlab](http://www.mathworks.com/help/matlab/ref/imread.html) page about reading image? It also talks about tiff image format as well. | |
Re: If there is no weight of traveling time for each person, any permutation is correct. However, once you add weight values, then you will see whether or not your algorithm is correct. | |
Re: >summary = text.replaceAll( ("<[^>]*>", " ").substring(0, 150)" , "..."); Your code syntax is still wrong. Also, even if it is correct, your logic could fail again. The reason is that you *modify the String* before you take its substring. If you are going to modify a string, do it **before** … | |
Re: The reason you need compareTo() because you need to know which branch you are going to work when 1)the key is not found at the current searching node and 2)the direction you will go down the tree (either left or right). The compareTo() will give you all information at once … | |
Re: >Queue<ProductMessage> prodQueue = new ConcurrentLinkedQueue<>(); Are you sure that it is supposed to instantiate that way??? | |
Re: You need to read about [method declaration syntax](http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html) before you can go any further. The reason you are not getting it is because you declare it wrong. You need to know which part means what... public static int[] printElements(int num) ^ ^ ^ ^ ^ | | | | | … | |
Re: In the function called by onclick, pass in the div ID. Then in the function, reassign the value you want to the div ID. @JorgeM, the OP said "*Require 4 buttons each one to change the text within the div* **--> ie <--** *button "info 1" to change the text … | |
Re: Your requirement is oddly worded... I assume that you are talking about adding "bye" file if there are less than 44 files... Before going to the for-loop, outside the whole try-catch portion you posted, you need to create a flag and may name it as *found*, and then assign it … | |
Re: To explain why the script portion doesn't appear in Firefox, you need to briefly understand how the JQuery internally works. The script will detect which browser is being viewed by the client, and then create a proper object which should be compatible (functionalities) with the current viewing browser. The issue … | |
Re: >Am I using too many classes? No, you don't. A good way to do OOP is to break down a big object into smaller objects. Your classes look fine to me. If you feel that there are too few classes, you could still break it down further in the future. … | |
Re: Stealing code? Well, if you put anything on the Internet, you have to sacrifice your privacy. If you don't want it to be stolen/copied, you don't put it online. It is similar to putting your nice painting in a show room and let others see and take pictures. Then you … | |
Re: Hmm... How about this... I am guessing you implement all your classes in the same file? Even though they all are in the same file, each of them has its own space. In other words, each class has its own visibility and they sees only whatever implementation inside themself. There … | |
Re: I'm sorry, but I would love to see a better comment that just that. The reason is the function name explains itself, but what does it mean... I would like to see comment somewhat similar to below. Do not be too shy about commenting script/code. It will save your behind … | |
Re: OK, your problem is about using random number generator. When you think about staying in a middle of a 7-foot bridge, it means the precision is important! Do not use *int* data type to represent where you are. Currently, you place yourself at location 3 which is NOT the middle … | |
Re: Edited. I think the table is as follows? Current: P1 3 1 0 0 P2 0 0 1 2 P3 0 2 3 4 Max: P1 3 4 4 0 P2 0 0 1 3 P3 3 4 4 6 | |
Re: You may read [this](http://www.chromium.org/Home/chromecompatfaq) around the bottom of the page. It states the bug about how IE read object tag instead of embeded tag. Also, it is about Google Chrome browser. | |
Re: The ability to programmatically think and to find a solution to a problem are not the same. You can find a solution using different aproach which is not by programming. In programming, you may need to apply maths to solve a problem; however, many problems do not require maths in … | |
Re: You should read stultuske links. They will help you to understand the language. There are a lot more involved in the reason. To give you a short answer, a class can inherit from only 1 class at a time. You cannot inherit more than 1 class unless you inherit from … | |
Re: Not to read your code but from what I see, the location of the ball is the center. Your script is checking the location of the red line against the center of the ball, not the edge of the ball. As a result, the location which is supposed to be … | |
Re: Did you check what is added to your *test* variable? That would help you understand what is added and why it is not found. for (String item : test) { System.out.println(item); } PS: *stultuske* is faster :( | |
Re: Simply declare *number* outside the 2 for-loops and may initiate a value that will never expect to be seen from the return inside the inner loop (a negative number maybe?). Also, declare another variable and may name it *numberToSkip* outside the 2 loops too. Inside the first loop layer right … | |
Re: You may read one of matlab tutorials [here](http://www.math.ufl.edu/help/matlab-tutorial/) or this [official site](http://www.mathworks.com/academia/student_center/tutorials/launchpad.html). The given code is to generate a horizontal array (dimension 1xL) value from 0 up to L-1, and then store it in variable *nn*. Then create an vertical array size of Lx1 filled with all 0 except the … | |
Re: >"^In our tests, downloads on port 6881\D+(\d+)\D+(\d+)" If that string works for you, you could easily do... "^In our tests, downloads on port 6881\D+\d+\D+(\d+)\D+\d+\D+(\d+)" Anything inside the parentheses are the group you are caturing from the match. | |
Re: When you see nothing happens in an interactive GUI, the first thing you should look for is the *actionPerformed()* method. The method is from *ActionListener* which is a class that keep listening any event from the frame/panel your program is being displayed. Currently, your method definition is calling to exit … | |
Re: From a quick glance on your program, line 75 is not needed. Also, line 76 will cause a problem because you are not counting nodes after you have already initialise the list once. Also, you may need to implement the swap() method before you could go further. The sort requires … | |
Re: You do it exactly the same way as sorting a String array. The only different is the way you traverasal the list and the way you swap the items. If you still don't get the idea, I will come back and check on it later... | |
Re: No, I think lines 48~50 are causing the problem (in main()). The reason is that all of those variable being passed to methods are not declare/initialised anywhere inside the main(). I believe the professor asks the OP to enter a real number, not a variable. // i.e. Sphere.volumn(5); ... But … | |
Re: Are you talking about the display inside the grid? If so, you simply display a panel inside that row. Then manipulate (repaint or swap out) the panel for different content display. | |
Re: Do you understand the closest distance equation between 2 points on 2D? It is... distance = square root of ( (x2-x1)^2 + (y2-y1)^2 ) The distance() method is done exactly what the equation is. When you do normalization, you are converting a vector it its unit vector (magnitude of 1). … | |
Re: You need to create a table of double value and at the same time keeping track of the value you need for the total sum. The maximum value of the double value will never go above the multiplication value you want it to be. /* i.e. You want to do … | |
Re: >The program has to randomize the array indexs. What does that sentence mean??? If your program generate a random index of an array, what's next? Your program is importing *Random* class, but you instead use *Math.random()* method to generate a number? What you need to do is to follow the … | |
Re: The double and single quotation marks are often times interchangeable. In this case, you must distinguish which quotation marks you are using. You could use an escape character (backslash) to make this happen. document.write("<input type=radio name=\"overall\" value=\""+i+"\">"+i); | |
Re: Whenever you got an error saying *Symbol not found*, you need to check the name given by the error. There are usually 2 causes of this type of exception. One, Java language is case-sensitive. In other words, a variable name *Number* is not the same as a variable name *number*. … |
The End.