• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I Was Thinking, Yah, Scary

 
Greenhorn
Posts: 29
Firefox Browser Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recently got back into Java (Beginner, very much so) and I was trying to think of a program I could write, but I am not sure how to go about it, since I don't understand how the logic works in labeling.

My initial thought was, what if I start at a point, say, 0, then travel east, north, south, west no more than 3000 steps. Why 3000? No reason, it just popped into my head, so I am going with it. Well, since Java is object oriented, let's just make it squares (say, a chessboard). So, you have Block 0, then you can travel four directions. But how do you label them? My ultimate goal would be to progress the program so that it tells a user to choose a block, then program tells user how many blocks away from 0 it is, not just horizontal-then-vertical, but also diagonal. Then, to make it even more complicated, eventually add a two-point input, then tell the number of blocks away from those, including diagonal distance.

This is where I do not understand the logic. I understand the numbering X, Y, but what about a jump 64 east, then 64 north? Do I label each block the coordinate, or is there some weird math/logic involved in naming it? And aside from the names, what if I do use the coordinates, how would I tell the program what fits the bill for "shortest route"? I can set up the logic to left x-number, down y-number, but will that always be the shortest route? Diagonal will not always be a straight shot, it will likely be three west, one south, three west, one south, until the final point. But even if it keeps that pattern, what if in the last stretch to hit the square, it only needs one south to hit it? Sheesh, who'da thunk finding the shortest distance between two points would be so hard. Seeing it on a graph it seems simple, but once I draw the blocks and see the patterns go all wonky at times, I start to wonder if I can really screw this up and not do it right.

I was trying to think of a good example, but all I can think of is Minecraft. Looking here at the pocket edition I can see that the map has coordinates for where you are in-world... but how does the labeling of the blocks work? I am not interested in the depth; I can mess around with that much, much later when I get better at this. Is this a complicated process or am I just getting overwhelmed due to my lack of sleep?

I am going to bed, so no rush on the advice. I am very curious how the logic works and feel this would be a good exercise to test what I have learned the past few days, so maybe I can pull this off and learn something else while I do. Sleep well, friends. Goodnight.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When modeling some idea in code, there's almost never one correct way to do it. You can do it in many different ways, and each way you do it has its own advantages and disadvantages. This is really where most of the art and creativity is in when you're designing a program.

I once did a programming workshop where all the participants got an assignment to make a simple game (I don't even remember exactly what the game was). You could choose any programming language you like and design it however you wanted. There were about 25 participants, and at the end of the evening we looked at each other's solutions. It was amazing and very interesting to see the variety, and the many different ways in which people modeled the game logic in code.

If you have this idea as you described in your post, then first think it through a bit (I see you're already doing that) and then just try putting it into code. You'll discover what the advantages and disadvantages are of the way you've modeled it. Then think about how you could do things differently and try that. You'll learn a lot about designing programs.
 
Greenhorn
Posts: 7
Netbeans IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I really like this post and the response. I am a very new to all of this but I read A LOT. One truth that I have found to this point(after 17 years) of building electrical systems and data networks from the ground up, is that there is always more than one way to get the job done. With that said, I believe that this is or probably is true of programming. The point I want to make is, that , just like a fingerprint, no one way of getting the job done is the same. My logic doesn't = your logic but I bet you a hundred dollars to a dohnut, when the idea is completed, it will do the same job. The only difference is.....wait for it.......experience!!! Been there done that. Time to learn something new. The great thing about learning is....with an open mind, the questions come just as fast as the mistakes. If you aren't F%$#n' it up, you ain't learning. So, read a book or two, God bless ya and F$^# something up like you won't have the chance tomorrow. LOL
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And one advantage of programming is, if you make a mistake when you're putting your program together, you don't set your garage on fire when you try to run it!
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would say that your subject should be "I was thinking...yeah - that's AWESOME".

it is amazing how many people believe that programming is about tying into a computer. Real programming is actually 80-90% thinking, and only 10-20% typing.

So please...KEEP THINKING!!!
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:And one advantage of programming is, if you make a mistake when you're putting your program together, you don't set your garage on fire when you try to run it!


There was this one guy who was trying to automate his house with X10... he had a refrigerator in the basement and another one in the garage and, well...

And then there was that business with the rocket and the floating point conversion error.

Never underestimate the extent of damage a programming error can cause.

(Ok, that first example is made up but the second one actually happened in June 1996)
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote: . . .t the second one actually happened in June 1996)

And would have wrecked your garage had it landed on it!
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh yes, lots of things can go seriously wrong, like patients getting a massive overdose of radiation, rockets self-destructing, fighter jets flipping upside down when they cross the equator, and many other serious consequences.

But those things won't happen with your personal learning projects and experimenting is one of the best ways to learn programming.
 
Drove my Chevy to the levee but the levee was dry. A wrung this tiny ad and it was still dry.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic