Help coderanch get a
new server
by contributing to the fundraiser

Timothy Oldbean

+ Follow
since Jun 23, 2011
Merit badge: grant badges
For More
Amsterdam, the Netherlands
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 Timothy Oldbean

Thanks a lot Michael!

I'm going to take my time tomorrow comparing your code to mine and see where I went wrong. By the first look of it I see you doing a couple of things I haven't seen yet and thus don't understood so I might have a couple of extra questions later after I try to find it out myself.

12 years ago
Stuck for hours and as soon as I post here I start getting somewhere.

I think I've got the getter and setter part sorted now:

The challenge I have now is to get the value of boolean swoosh into the if else statement which I'm wrongly attempting to do like so at the moment:

12 years ago
I'm trying to get the boolean to work in another class through using getter and setter but now I've run into a new problem. I get an error on the getter method.

12 years ago
EDIT: Obviously a beginners question! Probably in the wrong forum, please feel free to move mods! Apologies!

I thought I'd help myself understanding the GUI and ActionListener proces a bit better by sussing out how to do something simple like putting a button and a rectangle on a screen and then having it change color from blue to red on buttonclick.

Appears I've ended up in a swamp and everytime I move I get sucked farther in.

I soon found out I have no clue how to easily change the color of something when clicking a button so I thought I'd fake it first by simply running a different color panel on mouseclick. And that failed miserably too! Trying to use the boolean swoosh in two different classes is not the way to go. So a little help, hint or push in the right direction would be greatly appreciated!

12 years ago
Hi Oliver,

Java is the first programming language I'm learning. (well since an ok grasp of basic on the MSX for a 9 year old long time ago :-)) I'm 37 and just started my bachelor in software engineering.

I'm having a much harder time at getting it then I initially thought I would. Especially the OO track of thought was a challenge. And you are absolutely correct I can see that it's hard to understand a bit if you don't understand it all so you need to find a way to cram it all in your head at the same time until it clicks.

But I must say that the incubation time seems to be over and I'm settling in rather nicely and starting to feel more and more comfortable and I've passed to point where I have any doubt if I'll "win" this or not. I've even started making my own text adventure just to try out concepts on my own without the benefit of an answer on the next page. This has accelerated my understanding greatly by the way.

One thing I did run into, and maybe the same goes for you, is that I didn't like the book I was learning it from too much. It's the one the module Java in my study works with and also seems to be the book everyone here advices. Head First Java. It's not a bad book, and now that my understanding is progressing and I'm looking at earlier chapters my appreciation for it is growing. It's just that it's put in a manner that rubs me the wrong way. My solution was to get another book and start reading that too and get another point of view. My choice was "Thinking in Java" by Bruce Eckel. Now I feel that book might have also been a bit too dry and catered too much to people transitioning from C had I not have a head start (no pun intended) in Head First Java but together they worked great for me.

I've also started doing the excercises here: to get some extra practice under my belt and confidence boosts.

The choice if you'll keep going with Java is of course yours but I think you'll run into the same problems in C (and then some due to memory management) and any other truly OO language and you'll have to learn one sooner or later to gain easy entry into the others.

Whatever you do, good luck!

12 years ago
Hi Angela I'm new here too so I'm not a lot of help yet. You can make the code a lot more readable by using the "Code" button.

I'm pretty sure someone will come along with an answer to your question soon :-)

12 years ago
Thanks a lot Ralph!

Both your explanation as running the code with the line you added with the x, y and z outputs have greatly helped me get this.
12 years ago

Ralph Cook wrote:x loops 10 times; for every time that x loops, y loops 10 times
so for x == 0, y goes from 0 to 9
x == 1, y goes from 0 to 9


therefore, the z++ executes 100 times.


Aha. So I think I didn't get the first one then although I ended at the same number.

Am I right when I say that if by taking your explanation and applying that to the first one y already hits the 9 after the first go through from x and then remains that until x also reaches 9? After that it moves on to the z = x * y for the 81 output. Sure hope it does because then I get it now

I was (probably) mistankingly thinking that the loop stuck in the x until it hit 9 and only then moved on to the 2nd one until y hit 9 and then hit the z = x * y for the 81 output.

Sorry to have to ask again, guess I'm not the sharpest tool in the shed. But I figure that being afraid to ask on until you completely get it is even less smart.
12 years ago

Greg Charles wrote:z++ is shorthand for z = z + 1. After doing that 100 times, you get 100.

Thanks for your quick reply!

The bit that z increments with one isn't wat confuses me. Somehow I don't get the 100 pass throughs. How does the loop pass z 100 times?

12 years ago
I'm doing an excercise for school and I'm not understanding where the output comes from.

It starts with this:

Here the the output of z = 81 and is crystal clear to me.

But then they change the z = x * y line into z++ like so:

And the output of z = 100 now. And that I don't get. As I'd say that it should be 1 I'm not getting something. Can someone help me understand how the z turns into 100?
12 years ago
That is a very elaborate and very clear answer.

Thank you very much I can now start digesting this!
12 years ago
It's an array!

Never underestimate the power of stepping away for a couple of minutes and a couple of sips of Crown Royal as a reward for putting in some study hours.

So I get now that the first loop is actually filling up the 6 objects in the obs array. And as it's done before the y = y * 10 it would look like:

obs[0] = 1
obs[1] = 10
obs[2] = 100
obs[3] = 1000
obs[4] = 10000
obs[5] = 100000

So the solution lies in what ivar does with those numbers in Puzzle4b class after the boolean.

At least one part is tackeled, I think.
12 years ago
I've hit a wall and I can't get my head around it.

I'm doing my bachelor in software engineering from home so I don't go to any classes. Also I don't have anyone in my direct social circle who knows Java.

Up till page 90 I was getting it pretty well but somehow a concept is not clicking so I'm hoping someone could dumb it down enough for me to get it.

the output is: result 543345 and I simply don't get where those numbers come from. Really not a clue.

One thing I don't understand is what for instance obs[x].ivar does. Does the value of of the new Puzzle object with a reference of obs[x] become the same as the integer ivar?

Same thing with result = result + obs[x].doStuff(x); I'm not sure what I have to do with obs[x].doStuff(x); Or better put, what they are doing to each other.

It's frustrating me to no end as I was cruising along nicely, getting all of it, and suddenly this pops up and I'm not sure where it was covered in the book. I'm also suspecting it's not that hard and if I read back this post in a couple of months I'll hang my head in shame and answer a couple of other beginners patiently just to make up for it.

I think y gets up to 1.000.000 in the 6 times it goes through the first while loop. And then we also go through the second while loop 6 times which modifies integer result every time.

So if anyone could in as simple as possible words explain the logic here. Don't worry, you won't hurt my feelings! That would be fantastic!

12 years ago
I'm just learning Java so I can only share what I see as my path but can't speak from experience yet.

You can get some practice here: and here:

there are quite a few similar sites with more problems.

Apart from that you can check out some of the freelance coding websites and see if someone will let you build something simple for way too little money. Just to get some real life experience with an actual customer under your belt.

And then there is the open-source stuff mentioned before.

Hope this gives you some ideas!
12 years ago

Just testing how the [ code] [ /code] works. Take out the space before code and /code to make it work for you too!
12 years ago