• Post Reply Bookmark Topic Watch Topic
  • New Topic

This Old Man code from Art and Science of Java  RSS feed

 
Maylom Ventura
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey

I'm also learning from this book so I don't know how clean the following code is but it works:


 
shuba gopal
Ranch Hand
Posts: 86
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Maylom

Welcome to the ranch

This code looks great
 
Campbell Ritchie
Marshal
Posts: 56576
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I still prefer the array example given previously. You have indented the }}} incorrectly. you should have each } on its own line, with its own indentation level. And what does it print for verse 7?
 
Maylom Ventura
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you both.

for verse 7, it prints out "He played knick-knack on my up to heaven". It thought that's the way the song goes but I guess i gotta take out 'my'.

I haven't gotten to arrays yet. Looking forward to that
 
Kristjan Toots
Ranch Hand
Posts: 59
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that by standard all constants should be uppercase...
 
Campbell Ritchie
Marshal
Posts: 56576
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kristjan Toots wrote:I think that by standard all constants should be uppercase...
That is a common convention, yes. There are some conventions which don't use upper-case, this one, for example.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I remember this song from school, long ago, where we learned in English class (English is not my native language). It's a song that gets stuck in your head, when I see this topic in the forum it starts playing in my head again.
 
Campbell Ritchie
Marshal
Posts: 56576
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I remember it from before you were born, Jesper We sang it about the age of 7. I presume we sang it as a counting game, like "ten men went to mow." We were too young to realise it is a song about drink, however.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!