7,116 Posted Topics
Re: Hello vivanie, welcome to DaniWeb DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Post what you have done so far and someone will help you from there. | |
Re: There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) … | |
Re: pricesolo: 1. This is the Java forum, Python has its own forum http://www.daniweb.com/software-development/python/114 2. DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules | |
Re: I'm not reading all that code either, but it sounds like you need a single controller class that deals with the database, keeps the timer(s) and creates or re-displays the question frame(s) as required. | |
Re: The version of exec that takes a single String as its argument is full of problems if you have a command with arguments, or spaces or quotes anywhere in it. It tries to parse the command/arguments itself and often gets it wrong. There is a version of exec that takes … | |
Re: That seems clear enough. Obviously Tester doesn't implement an add method, and doesn't extend any class that it can inherit add from. ps the paint method is seriously wrong. Every time it's called you add jName again. Depending on what's happening on the screen paint may be called many times … | |
Re: ^ like he said, plus you don't need to put the variable names in parenthesis `if (variable1 && ! variable2) ...` | |
Re: OK. So was there something you wanted to discuss or ask? | |
Re: I can't understand your description of the requirement! Maybe it would help if you gave a couple of examples of typical inputs and expected results. | |
Re: Hi goodtaste. Please don't be worried about the tough replies that some people get when they expect us to do their homework for them. Firstly this isn't a "we do your homework" service, and secondly we assume that the teacher has set a project that the student should be able … | |
Re: There's no one right answer to this, but here are two very short answers to start the discussion... If those values represent something persistent about the MyTest instance that is relevant to a number of methods then they should be instance vars (with getters/setters) and should not be passed in … | |
Re: ... just shows why it's a good idea to compile (and even test!) any code before you post it here ... nothing gets past the eagle eyes ... makes you look a bit silly when you tell a beginner "do it like this" where "this" doesn't even compile :) | |
Re: > i can't seem to find the place to delete the articles you post There is no such place. You posted a real-life question and someone spent time and effort answering it. Now it's part of our knowledge base where it may help others in future. No way do we … | |
Re: When you create a Java program you usually create a whole load of methods. How does Java know where to start executing your program? So Java was designed to always look for a method `public static void main(String[] args)` and call that to start your program ps Welcome to DaniWeb … | |
Re: bguild's solution is certainly the simplest, and is probably all you need, but for future reference here's the general way to add any amount of into to an Execption: Create your own Exception by extending Exception, add the extra info to the constructor, have accessors for that info (or just … | |
Re: Hello JustLeftRavenholm, welcome to DaniWeb That's a whole lot of code. It's unlikely that anyone will take the time to understand a 600 line method with very few comments, a strange mixture of arrays and repeated variables (price1-20), and little or no indentation to clarify the structure. Exactly what is … | |
Re: How big are dx and dy? If, for example they ate 10, then your ball could be 9 or 10 pixels inside the player in just one clock interval. | |
Re: You may be thinking of interfaces like Serializable that have no methods. When you declare a class as implementing Serializable all you are doing is announcing that your class can be safely serialised. Such interfaces are caled "tag" interfaces because they tag a class as having some attribute that the … | |
Re: You can write Java programs to perform math calculations, solve equations, plot graphs etc, but that requires you to understand what you are trying to do. If you don't undertand the math, writing a Java program isn't going to help, in fact it will just add a whole load of … | |
Re: > from where will your toDate() method get its string? ??? Nobody has any such method! There *is* a toDate(String str) method, and it's obvious where that gets its String. | |
Re: If you look at the mouseClicked method you will see how that adds a counter - there's a simple method it calls. You jiust need to call that same method 3 times for each column in your initialisation. | |
Re: A lot depends on how robust you want he to be. A simple public static getInstance with a private constructor that's called from a static initialiser block is good enough for some situations, but there are all kinds of problems in a multi-threaded situation, or if you have multiple class … | |
Re: It may be a lot easier to extend something that has a paintComponent method, and include the rounded rectangle by composition rather than subclassing... class RRectText extends JComponent { RoundRectangle2D rect; String text; public RRectText(float x, y, w, h, arcw, arch, String text) { rect = new RoundRectangle2DFloat(z,y, ... this.text … | |
Re: Just read the API documentation for the String class - it's all explained there http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#String%28byte[],%20int,%20int%29 | |
Re: You could create a simple small test driver that starts multiple instances of the client, passing different values for host name, port number or whatever else can't be shared with its default value by two clients on the same meachine. | |
Re: The idea of pseudo-code is to capture/plan ypur logic without getting buried in the details of Java syntax or API method signatures. If you were writing this code for a non-programmer end user you may even be able to go through bits of the pseudo-code with him/her to confirm that … | |
Re: That looks 99% right! getSubimage (note capitals - Java is case-sensitive) is a method in the BufferedImage class, so you need an instance of BufferedImage to call it, eg `myImage.getSubimage(0, 0, 100, 100)` returns the top left 100x100 pixels of myImage as a new BufferedImage | |
Re: You seeem to be confused about the Date class. A Date object represents an instant in time, and has methods to access it. It does NOT have a format. When you convert a Date to or from a String that's when a format is applied. | |
Re: Step one is to disentagle your current GUI from the code about pizzas that you will need in the GUI version. eg at lines 23-35 you could create new method eg `choseSize(int size)` and move the code from lines 24-35 into it, so the code now reads: choice = inScan.nextInt(); … | |
Re: I don't understand what point your teacher is trying to make. The Java Language Spec doesn't use the term "attribute" except in two places. One is a very technical discussion of garbage collection, and the other uses it to mean a variable that can be accessed via get/set methods. So … | |
Re: Calling your class Applet isn't an error as such, but is guaranteed to cause problems since Applet is an exsting class in the API that you are trying to use at the same time. First thing to do is to change it to a unique name. (Don't forget to change … | |
Re: This is where the column names are created... for (int i = 1; i <= columns; i++) { columnNames.addElement( md.getColumnName(i) ); } .. so instead of that just add your own preferred Strings to the Vector colmnNames | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: Do not post articles that you have already published on another website Thread closed | |
Re: Just read the API documentation for the String class - it's all explained there http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#String%28byte[],%20int,%20int%29 | |
Re: Around line 8 you know how many bullets there are in enemyBulletStore, so maybe you could use that to pick a counter value for the next bullet. | |
Re: Lines 16-22: portList = CommPortIdentifier.getPortIdentifiers(); ... System.out.println(portList.nextElement()); while (portList.hasMoreElements()) { ... portId = (CommPortIdentifier) portList.nextElement(); This may be a problem. You call nextElement for the println, which will print the first element in the Enumeration, so your while loop will start with the second element (if any) in the Enumeration. … | |
Re: It's nothing to do with Parent/Child. It's because you have an executable statement (`avg = st_marks/2;`) that's not inside a method or other executable block. You could do that as an initialisation expression as part of the declaration of avg... | |
Re: 1 arr is an array of ints, setText needs a String, so you need to convert your value 2 SetText replaces any existing text, so setting it in a loop will just show the last value; you need to append att the text together. One way is to start with … | |
Re: Red_Rain Maybe you misunderstand what we do here. We are not a homeowrk service. There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your … | |
Re: That code looks like every Boss fires a new bullet on every pass through the game loop - that's a lot of bullets. Or is there some other code that determines how often a new bullet is fired? | |
Re: > ... ou dont need to write how a set of code conventions state ... Possibly the worst advice of 2013 so far in this forum. Even if you never write a single program for real, even your teacher will read and mark your code. Coding standards and conventions are … | |
Re: One possibility is a list where each element is a list of 3 numbers, but it looks like each line represents a single "something", so one obvious approach would be to create a "Something" class to encapsulate those 3 values, and have a List<Something>. That also puts you in a … | |
Re: In general (Windows), if you have a path with spaces in it you have to enclose the whole thing in " quote marks. | |
Re: Do you mean keep going down untill it's completely off the screen? I don't understand your hit method how often will that be executed? | |
Re: > StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead. Java 7 API doc for StringTokenizer | |
Re: Every time you call getDays you increment the elements of dayCounts - I can't see any code where its values are reset. Eg the loop counter on line 36 calls getDays each time the loop is iterated, each call incrementing dayCounts. | |
Re: If you are using Eclipse then ou could use its debugger to trace the execution of your program to see what is, and what is not, being executed. If you don't know how to do that yet, just add print statements at key points in the code so you can … | |
Java SE JRE 7 update 21 is now available, with fixes for dozens of security-related issues. Immediate installation is highly recommended. Head on over to Oracle's Java download page and grab it now. There is also a version for Java 6 users, if any such animals still exist. | |
Re: Just to understand what you are saying... the option pane on line 9 displays, but then you do nor see any of the option panes on lines 18, 21 or 25? |
The End.