|
fret logic posted:When I was thinking of the addition, I was implementing reducing to the lowest terms. This looks like it just multiplies the denominators and leaves it like that. It says in the instructions that in the next project they will reduce the fraction to it's lowest terms. For now it's enough that they just keep multiplying the denominator.
|
# ¿ Feb 26, 2008 08:11 |
|
|
# ¿ Apr 27, 2024 08:09 |
|
If you can change your objects you can have them implement the Comparator interface. Now you can use the sort the function in java.util.Collections class.
|
# ¿ Mar 5, 2008 04:35 |
|
I agree with posting your code. Your problem doesn't make much sense, it should work.
|
# ¿ Mar 10, 2008 09:10 |
|
Well your approach isn't very OO yet. I'll try to critique your Player class first. You are limiting yourself by defining the 2 playerclasses. A much more robust constructor would be this. code:
Your method updateStats should be changed to override the toString method since you are not actually updating any of the stats. I think the only method that is missing from the Player class is a combat method where he can do damage to another Player. I'll let someone else comment on your GameLoop class because I have to run.
|
# ¿ Mar 11, 2008 04:04 |
|
There is Bruce Eckel's Thinking in Java which is available online for free. I've been reading his C++ book and I like it very much. I can't think of any Java tutorials, but frankly you should stay away from them. Tutorials rarely cover any subject in depth so there usefulness is limited.
|
# ¿ Mar 11, 2008 12:05 |
|
Incoherence posted:There's one catch: you'll want to check that each of your four/eight adjacent points are inside the matrix, but what you want to do about that will depend on whether you want to wrap around on edges or just drop them. I've always wondered what people do when you just want to drop them. In the past I've surrounded that block of code with a try/catch that doesn't do anything when an IndexOutOfBoundsException is thrown.
|
# ¿ Apr 11, 2008 03:20 |
|
Incoherence posted:If I ever saw anyone use a try/catch I'd go put it in the Coding Horror thread posthaste. You are right, I was too quick to post. Here is what I actually meant, I had an algorithm that would traverse the array diagonally. The problem I had was dealing with 01, 02, 04, 06, 08, and 09. So I put it in a try catch and let it keep doing it's thing. 01 02 03 04 05 06 07 08 09 As I posted this I realized that I could check to see if it was out of bounds and just use the continue statement.
|
# ¿ Apr 11, 2008 05:17 |
|
Maybe he means calling the pack method on the window. Window.pack()
|
# ¿ Apr 13, 2008 17:50 |
|
When my kids start learning how to use objects I go out of my to explain this to them. But yeah I don't think the Deitel book even offers an explanation.
|
# ¿ Apr 19, 2008 03:41 |
|
I discovered something awesome about java today! Labeled loops I had a triple nested loop and the two inner loops were traversing the same data structure. I wanted to be able to break out of two loops and using a flag for this kind of stuff annoys me. I did a quick search and found the labeled loops. After reading some more I realized that you can label any block of code and effectively have a goto! It seems like it could be misused, but I'm happy with what I used it for. code:
|
# ¿ Apr 24, 2008 23:06 |
|
Well if you assume that a person can't have a number in his name and that the student ID is made up of all numbers then you can reasonably separate the fields. The hardest part would be separating the ID from the email since an email can start with a number, so there would have to be some whitespace between the id and the email.
Janitor Prime fucked around with this message at 05:09 on May 23, 2008 |
# ¿ May 23, 2008 05:01 |
|
Led posted:I don't know if this is the right thread, but does anyone want to test my Java applet for me ? Well it loads and works on my Kubuntu 8.0.4 x64 machine. Also it said that a picture of a flower was indecent. edit: I forgot to mention I'm running Sun's Java 6 and Firefox 2 on this computer. Janitor Prime fucked around with this message at 20:52 on May 28, 2008 |
# ¿ May 28, 2008 17:01 |
|
Well another problem with your code is that you trying to save their name as an int when you should be saving them as Strings. The only things that are ints are their age and height. You should also tell them to specify their height in inches, that way you don't have to parse feet and inches. You are also missing the types for the fields first, last, hieght, gender, and your drivers license field is repeating. edit: About JCreator, don't worry about the black box, your output will be in a small white box at the bottom of the screen. The reason you can't type in it is because of all the compiler errors I mentioned above. Janitor Prime fucked around with this message at 13:04 on Aug 6, 2008 |
# ¿ Aug 6, 2008 12:59 |
|
That's loving retarded, why would you ever want that. Since your fields aren't private and they are all in the same package, I think you should be able to access each one's X by placing the class name dot x. TestClass.x NestedTest.x NestedNestedTest.x and x
|
# ¿ Aug 15, 2008 15:25 |
|
Maybe the super keyword can help you. I don't know if it actually works for anything other than methods.
|
# ¿ Aug 15, 2008 21:50 |
|
Java 6 comes with derby now if that means anything.
|
# ¿ Aug 21, 2008 00:29 |
|
I have a question about find bugs, it reports a possible NullPointer on the bolded line.code:
|
# ¿ Aug 28, 2008 20:09 |
|
Mustach posted:The lesson is that everything that depends on input should be in the try block: Duh. Thank you for clearing that up.
|
# ¿ Aug 29, 2008 00:46 |
|
zootm posted:I'd consider this pretty bad style - it's usually best to avoid putting code that doesn't throw a given exception in a 'try' block which catches it. Removing the '= null' from the variable declaration will cause the compiler to check that any control flow to a line where you use the variable definitely assigns it. What would be another way to terminate flow? Just a simple return?
|
# ¿ Aug 29, 2008 13:15 |
|
Flamadiddle posted:It's just that the use of the database makes what we want to do much simpler. Would it make more sense to make a call to a server side application or something to seperate the user from the database? This is the correct way to do it, you don't want random people on the internet to have direct access to your database.
|
# ¿ Sep 17, 2008 15:16 |
|
Flamadiddle posted:My applet will just be a GUI for people to enter the message and that'll just get passed to the server. Honestly a simple html form is all you need. No need to even make an applet.
|
# ¿ Sep 17, 2008 22:11 |
|
If you look at the String API, you'll see that there is no such method as doubleValue(). What you need to do is use the Double class to parse your strings like so.code:
|
# ¿ Sep 18, 2008 01:07 |
|
LakeMalcom posted:If order matters, then roll your own little map to put and get the reverse order string. The TreeMap lets you take ordering into account.
|
# ¿ Sep 28, 2008 02:31 |
|
Incoherence posted:Hm, somehow missed this earlier. My only counter argument to this, how often do you go back and look at your own code from semesters past?
|
# ¿ Sep 30, 2008 13:11 |
|
First of all you should be using generics, it makes your code much easier to work with since you don't have to cast your objects all the time. This has some other benefits like preventing accidentally adding an object that isn't a Calc into your arraylist.code:
code:
Janitor Prime fucked around with this message at 04:55 on Oct 28, 2008 |
# ¿ Oct 28, 2008 04:52 |
|
quote != edit
|
# ¿ Oct 28, 2008 04:53 |
|
You shouldn't compare objects with ==. Trying using the .equals method of the string. if( direction.equals("E") )
|
# ¿ Nov 1, 2008 02:17 |
|
Create another class, not an anonymous class, that receives an integer in it's constructor.code:
|
# ¿ Nov 16, 2008 17:32 |
|
Eclipse is written using SWT, so I would imagine it has a nice SWT designer. Maybe you overlooked it.
|
# ¿ Dec 13, 2008 23:12 |
|
Lets look at the Java API for the String class.code:
In order to call this method you have to have an existing String object like so: code:
If the statement in the question were true then in the API there would be a static method in the String class that received a String like so: code:
code:
Janitor Prime fucked around with this message at 23:19 on Dec 16, 2008 |
# ¿ Dec 16, 2008 23:16 |
|
Logostomp posted:Am I really hurting anybody by asking a question? I'm not asking for the answer. Just asking for some help. But you are not asking for help, you are asking for us to do your homework. An example of asking for help would be, "How should I store all the numbers as they come in?". Your so called question can be answered by a 1 second google search, you already know how to compare 2 numbers.
|
# ¿ Feb 12, 2009 18:50 |
|
Ant is another alternative to Maven and a lot of projects still use ant.
|
# ¿ Feb 19, 2009 20:27 |
|
jstirrell posted:Poker Stuff I didn't get a chance to look at your code, but with a quick glance I noticed you had a lot of constants in your code. Read up on Enums, they replaced the public static int paradigm. As a bonus, that tutorial has some code for creating a poker deck! Some of the code might be over your head so feel free to ask us any questions about it.
|
# ¿ Mar 5, 2009 22:21 |
|
The way your class is right now won't let you take advantage of the toString method because you hardcoded the number of sides. So what you should do is declare a variable called sides and define it as 4 in the square and 12 in the cube class. That way you can reuse the toString method you defined in your square class.
|
# ¿ Apr 23, 2009 17:34 |
|
Shavnir posted:What do you mean visible to each other? Do you want to see them listed next to each other or something? I think he wants them to be automatically imported when he creates a new class.
|
# ¿ Jun 8, 2009 03:33 |
|
Mustach posted:Yes, let's teach beginners to stubbornly ignore all non-Sun libraries and tools like parser generators, etc. There are these things called JARS that you can include in your project. If your IDE is using some proprietary JARS that aren't being copied in the project folder, it sucks!
|
# ¿ Jul 20, 2009 02:48 |
|
I don't know what you original question was but I'm pretty sure it could be fixed by a fixed place decimal class. Java also has the BigDecimal class which is part of the standard library and could probably serve your needs. Just keep in mind that working with theses classes is slower than their primitive counterparts (float, double).
|
# ¿ Aug 1, 2009 15:46 |
|
If you know ahead of time that the item will be altered, why not just send it a temporary copy?
Janitor Prime fucked around with this message at 16:44 on Sep 1, 2009 |
# ¿ Sep 1, 2009 16:40 |
|
You do know that this is the Java and not the javascript thread right?
|
# ¿ Sep 16, 2009 20:34 |
|
|
# ¿ Apr 27, 2024 08:09 |
|
The = operator is not the same as the == operator. You need to use == in order to compare two numbers.
|
# ¿ Sep 28, 2009 04:19 |