889 Posted Topics
Re: When the user inputs the numbers, you will have a String. Take a look at the API for the StringTokenizer class - I think you will see that this will be a useful class to separate the numbers (called tokens) by the commas (separators). Hope this has given a hint … | |
Re: I think you might be better off listing your GUI components outside the methods. You still initialise your components inside the swingMenu method, but doing it this way gives global access within the class. For example, [code=java] import javax.swing.*; import java.awt.*; import java.awt.event.*; public class SwingMenu implements ActionListener{ JMenuBar menuBar; … | |
Re: The only problem I can see is that your division is an int / int which is always an int. For example, 10 / 4 is 2 (not 2.5). In order to fix that you will need to cast the result to a double or float by doing the following: … | |
Re: Hi neow and welcome to Daniweb, I'm not sure what you meant by the statement: [QUOTE=neow;496269] my problem is how can i compute the operands that i inserted. [/QUOTE] Do you mean how do you get the operands from the user input? Or are you asking how to compute the … | |
Re: [code=java] for (int s:a) [/code] is shorthand for [code=java] for (int s=0; s<a; s++) [/code] in Java. I'm not sure if you can use printf statements like the ones you have there though - that's a C++ thing. | |
Re: The Math.abs function returns the absolute value of the number passed in as a parameter. Check out the java API for more information. | |
Re: Also use i>=0 rather than i=>0 in your for loop. | |
Re: I think masijade was talking about the method [code=java] Integer.parseInt(String s, int radix) [/code] Check out the API for this static method which parses a String s to an Integer value in the base radix. | |
Hi all, I was wondering what everyone thought were the most influential computer games of all time? It doesn't matter what platform, but I thought I'd break it down into genres, so here are some that I thought might be considered: First Person Shooter: Unreal Tournament / Doom Real Time … | |
Re: [QUOTE=MidiMagic;481923]Here they are: THE ANSWERS: 19. What is the largest island in the world? Greenland. [/QUOTE] Australians are very proud of the fact that our mainland is roughly three times the size of Greenland and is in fact an island, being completely surrounded by water. Greenland is the second largest … | |
Re: What don't you understand about Exceptions and Threads? They are two pretty broad topics so please try to be more specific and we will try to help :) | |
Re: I think this error occurs when you haven't properly defined your class and often it is that the class name and file name are different. Please post your code (using code tags) so we can give you a more specific solution. | |
Re: Hey there satya5321, You have answered a couple of threads in the Java forum today that have already been fairly well finished and are over three weeks old. Please check the date of the last post before replying to a thread. Cheers, darkagn | |
Re: [code=java] for (i = intArray.length-1; i>=0 ; i--) { // sort at end of list for (j = 0 ; j < i ;j++) { // "bubble" the largest value to the end if (intArray[j] > intArray[j+1]) { // compare each element to the next one temp = intArray[j]; // … | |
Re: I'm a bit skeptical that a trainer would assign a newbie to java such a large scale project with four days to complete it (in J2EE no less!) | |
Re: One advantage of lists that I can think of is that it is often easier to rearrange the data in a list because you are working with pointers. That is, if you have a list of objects and you want to change the order of the data, you can simply … | |
Re: It might pay to repost this question in the "Shell Scripting" forum if you want to specifically use a batch script to do this. Someone there may be able to help. Good luck, darkagn | |
Re: I haven't used a mac for quite some time so I could be wrong, but don't most macs come with g++ these days? You can use it from your Console utility and should be a sufficient compiler for a starter programmer. | |
Re: Hi and wecome fellow Aussie! (We are slowly taking over Daniweb) <insert evil laughter> :D | |
| |
Re: Hi namitiet07 and welcome to daniweb, Did you have a question regarding this thread? | |
Re: Hi Richard and welcome! I travelled to Costa Rica this time last year with my wife and fell in love with the country. We were in San Jose for Christmas and saw the Tope festival. I loved Manuel Antonio, Samara, Monteverde, Isla Tortuga... I could go on for hours :) | |
Re: Welcome scholly! It is always good to welcome a fellow aussie to this forum :) | |
Re: Well for starters you are calculating the area and perimeter of a circle rather than a triangle. Not that you are actually calling these methods though. Also your OR and AND statements in the if-statement in your getType() method needs || and && rather than | and &. And you … | |
Re: Maybe you could create a fairly simple Score class that records the player's name and score, and use an ArrayList of Score objects to record the order of high scores. Then to display them, possibly use a JDialog or JOptionPane? Check out sun's tutorial on using dialogs for more info … | |
Re: Hi cbalu, Do you know what a the difference between a static and non-static method is? Do you know what an interface is? Let me know your thoughts and I will try to help from there. :) | |
Re: Yes, instead of Object job; put Employee job; This will allow you to create any Employee or child-class. This is called polymorphism and is a fundamental concept of Object Oriented programming. Google 'polymorphism in java' for more info. | |
Re: I like the solved threads count. But maybe as a compromise the moderators/administrators of daniweb could have this info removed from their profiles? After all, they are moderators so we all know how good they are ;) | |
Re: Because you have not initialised i in that method. You do in the method before it, but i is outside that scope when you actually use. Also, the same can be said for the variable z. | |
Re: I'm not sure about source code, but you might find some algorithms by searching in google. | |
Re: The Oxford Dictionary defines racism as: [quote] [B]1 a[/B] a belief in the superiority of a particular race; prjudice based on this. [b]b[/b] antagonism towards other races, esp. as a result of this. [b]2[/b] the theory that human abilities etc. are determined by race. [/quote] IMHO Josh's discussion, entitled [I]Race … | |
Re: On the topic of climate change, Australia's new Prime Minister, Mr Kevin Rudd, has promised to ratify the Kyoto Agreement as one of his first orders of business. This means that the US is the only developed nation to refuse to sign. What is truly ironic is that the US … | |
Re: Ah I just realised that you are not actually calling the eatDot() method anywhere in your code. I think it should probably be called immediately before the call to repaint()... | |
Re: Set the text for a JLabel at the bottom of the GUI to be the following String: [code=java] java.util.Date currentDate = new java.util.Date(); String date = currentDate.toString(); [/code] | |
Re: I think I would do something like this in your Dot class: [code=java] private boolean eaten = false; // call this next method to set the Dot to eaten public void setEaten(boolean beenEaten) { eaten = beenEaten; } // call this next method to check if the Dot is eaten … | |
Re: Why do game developers put the option to cheat in their games anyway? To me it seems like a pointless exercise to play a game and cheat while doing it but maybe that's just me...??? | |
Re: Hi piers, The problem is that you posted a huge chunk of code that any of your fellow students could copy easily by searching for "scanner" in google. I think that is what the person is implying (possibly one of your professors?) Next time maybe just post the relevant code? ![]() | |
Re: Greetings fellow Australian. I too am interested in GUI design, although for me it is "Java or bust". I have dabbled in C++ but I find its nuances a little strange :S Anyways nice to meet you and hope to talk to you soon in DaniWeb! Cheers darkagn | |
Re: Not to mention this thread was nearly 18 months dead. If you need help, please start a new thread rather than resurrecting something so ancient... | |
Re: Hi Black Box, I've read a few of your posts and am impressed with your knowledge (of Java particularly). Cheers darkagn | |
Re: I'm pretty sure this should work: [code=c++] char c; cin >> c; [/code] I haven't tried it, but it only allows for a one character input I think... | |
Re: First, move the calls to numFactors to your main method. Second you need to implement the numFactors method which you can do by [code=java] for (int i=1; i<=n/2; i++) // since any num > n/2 is not a factor { if (n % i == 0) { // i is … | |
Re: A mouse listener can provide you with the x, y coordinates when the mouse is clicked and you can use these coordinates to check against your map to see which division was clicked on. | |
Re: A Lizard is a Reprtile which is an Animal. Therefore, a Lizard is an Animal. So I would say yes to your question. If you disagree, please discuss. | |
Re: Hi rheyang16 and welcome to daniweb, There are a couple of things to consider when posting - first this thread is 18 months old and your statement has nothing to do with the topic. Second, you have to be more specific - what do you mean by "i don't sometimes … | |
I received the following email the other day and thought it was worth sharing. I chuckled but maybe it's just my stupid sense of humour... :twisted: ----------------------------------------------------------------------------------------------- Are you male or female? Look down... I said look down not scroll down!!! | |
Re: Hi siri_lito, The rules of this forum are that you need to show an attempt before we can point you in the right direction. What have you done so far? | |
Re: What error are you getting? Or is it just a logic error somewhere? Nothing really stands out, but if you can describe how it isn't working I might be able to find something... | |
Re: [QUOTE=sherwood12;470172][CODE] int create_pascals(int a, int b) { /* This section of the code is checking to make sure that the two parameters passed into the function are non-negative and that a is larger than b. Otherwise we exit straight away. */ int cons = 1, row; if (a< 0|| b<0|| … |
The End.