Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Kristian Andersson

+ Follow
since Apr 23, 2004
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kristian Andersson

I have a little project on my spare time, featuring the developing of a simple and memory-insufficient calculator. In Java, of course.
Anyway, as the name of the thread suggests I want the numbers to appear from the right in the textfield of the calculator. The textfield that I use is, as the name of the thread also suggests, a "JTextWindow" (if this has any importance whatsoever). I don't see why posting my code should be necessary so far, so I won't do it for now.
Oh. And I guess I could use a StringBuffer to move the contents around each time the user inputs a new number into the calculator, but I was kind of hoping there was an easier way around, a method that does the job for me, or something like it.
18 years ago
I'm trying to find out what ASCII-numbers are equalent to the letters:
"c", "o", "m". Perhaps not the easiest way, but I set up this code:

I knew it wouldn't work. Somehow, I need to convert the int to a char, or whatever. Almost like the Integer-thing, but not quite. (And yes, I don't know the exact words or terms for "it". If anyone wants to explain it to me - go ahead.)
And by the way. If it would've worked, then I would've counted every printout on the screen until I stumbled upon the desired letters.
[ May 10, 2004: Message edited by: Kristian Andersson ]
18 years ago
Can you try to explain what passing an Object means? I'm quite lost when it comes to all theese terms. Which is why I don't dare to check the API. I did however, on this assignment.
I've tried to type something like this:
if (charAt(i) == "c")
but it doesn't work. I suppose I am supposed to get hold of the corresponding "char-number" of the letter "c". That is, say the letter "c" is the number "54" in ASCII-code, then I am supposed to check if:
charAt(i) == 54
right? That's quite clever, I should've thought of it before.
18 years ago
I got a rather silly assignment in which I am supposed to change all the "com"'s in a String, to "borom"'s. That is, the word "complicated" is supposed to be printed out as "boromplicated". And so on.
Anyway, I'm not asking of how to do it. The problem is, how do I check and compare the contents of a StringBuffer? I am supposed (and I happen to believe that it is also the best way) to use a StringBuffer, created from the original String that I have.
The way I'm thinking of doing this is:
1. Start a loop with the same length as the StringBuffer.
2. Every time in this loop, I want to compare the contents of one place in the StringBuffer to a "c". If it is a "c" then I shall imediately begin to check if the following letters happen to be "o" and "m".
3. If they are, I replace the three letters with "borom".
The code that I have is far from finnished, since the problem occurs quite "early". Anyway, here's the little code that I have managed to create so far:

Oh, almost forgot. Well, maybe not but. In short; the problem can be stated as (forgive me for all of the quite unnessecary chit-chat bove):
"How do I compare the contents of a char?"
....Well. This is the same as the name of the subject. o_O'
18 years ago
I got a class in which I want to call three methods. The problem is as stated in the subject of this post. I got no clue whatsoever of what I should to to make it work. Anyway, heres the code:

Would anyone please tell me what to do?
And if you want to help out further, I would like some help with the method "reverseArrayOrder". The point with this one is, as the name suggests, to reverse the array order. I either need a way to copy the matrix that comes with the method-call, or I need to create an empty matrix with the same size and use this to temporarily store contents of the arrays while moving their contents around. Right? I've thought of using an ArrayList, but I can't come up with a way to make it work...
18 years ago
Thanks for all the replies, but I believe that the last post is a bit more advanced than I can handle. To make matters more simple, all I want to know for now is how to loop through a matrix. I tried to write the following to loop through a matrix (with three String-arrays stored inside of it) named "matrix":

But it didn't work. I had three arrays stored inside of the matrix, and I could only print out the contents of the first array.
To put this shortly all I would like to know is how to go through the data stored inside of a matrix. The reason I am doing this is because of a task I was given from the college that I study at. It might seem as though I try to cheat my way through it - but the reason I made the post on this forum is because I couldn't find anything on the API-documentation, as a matrix is neither a class or method.
Thanks for all the help so far,
Kristian Andersson, Sweden
18 years ago
I'm trying to learn more about how a matrix works. I tried to find it at the API specification. But a matrix is neither a class or method and thus I had a hard time finding anything of value or interest.
Therefore, I hope to get some answers when posting on this forum. I wonder, how do I call a method when I use a matrix as an argument? And is there any way I can use something similiar to a StringBuffer with a matrix?
Kristian Andersson, Sweden
18 years ago