Results 1 to 9 of 9
- 02-14-2013, 02:18 PM #1
Member
- Join Date
- Nov 2012
- Posts
- 11
- Rep Power
- 0
Printing 2 2D arrays next to each other
Hello everyone, I'm making a battleship game, and it looks great already. I'm almost done but I'm stuck with my 2D array. I have 2 2D arrays (each one is a field where you can place ships on). I want to place them next to each other. Now I have to place them under each other. Anyone have a suggestion on how to do this?
thx in advance
- 02-14-2013, 02:27 PM #2
Senior Member
- Join Date
- Oct 2010
- Posts
- 316
- Rep Power
- 3
Re: Printing 2 2D arrays next to each other
Hi Matthieu,
I'm assuming this presented on the console as opposed to a GUI. As these are presented one over the other I presume you are looping through one array before looping through the next. Instead, try printing a line of each board before moving moving to the next.
Regards.
- 02-14-2013, 02:30 PM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Printing 2 2D arrays next to each other
Something like that.Java Code:for each row for each column on array 1 print value inset some form of divide character(s) for each column on array 2 print value
Your choice of what to use as a divide, but '<space>|<space>' seems reasonable to me.
ETA: In other words, what Ronin said...:)Please do not ask for code as refusal often offends.
- 02-14-2013, 04:11 PM #4
Member
- Join Date
- Nov 2012
- Posts
- 11
- Rep Power
- 0
Re: Printing 2 2D arrays next to each other
Can't I do this with a stringBuilder?
- 02-14-2013, 04:15 PM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Printing 2 2D arrays next to each other
The logic won't be any different.
Please do not ask for code as refusal often offends.
- 02-14-2013, 04:19 PM #6
Member
- Join Date
- Nov 2012
- Posts
- 11
- Rep Power
- 0
- 02-14-2013, 04:24 PM #7
Re: Printing 2 2D arrays next to each other
Reread Ronin's and Tolls' replies. They've told you how to do it.
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 02-14-2013, 04:27 PM #8
Member
- Join Date
- Nov 2012
- Posts
- 11
- Rep Power
- 0
Re: Printing 2 2D arrays next to each other
Don't get it how to do it,
- 02-14-2013, 04:29 PM #9
Re: Printing 2 2D arrays next to each other
Honestly, Tolls posted perfect pseudo code. Did you understand that? If not, what is the question?
We certainly won't provide the ready made code for you, but we'll gladly assist you writing it yourself.Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
Similar Threads
-
Printing multiple arrays help...
By Toffer_15 in forum New To JavaReplies: 8Last Post: 01-24-2013, 09:35 PM -
Error while printing out arrays
By cjgarcia in forum New To JavaReplies: 1Last Post: 05-03-2012, 12:34 AM -
Printing multiple arrays in 1 dialog box
By turbopenguin in forum New To JavaReplies: 9Last Post: 04-19-2012, 08:18 AM -
Printing Two Dimensional Arrays with for loops
By mcnam4119 in forum JCreatorReplies: 3Last Post: 10-06-2010, 05:27 AM -
Printing value of boolean arrays
By myst in forum New To JavaReplies: 7Last Post: 06-02-2010, 08:44 PM


LinkBack URL
About LinkBacks
Reply With Quote


Bookmarks