# need help with figuring out how to plot a point at a specific location

Page 1 of 1

## 4 Replies - 359 Views - Last Post: 05 April 2013 - 06:43 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=317698&amp;s=245ca3eabad15fd439e1e6d642e5e309&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Droidx

Reputation: 0
• Posts: 2
• Joined: 05-April 13

# need help with figuring out how to plot a point at a specific location

Posted 05 April 2013 - 01:28 AM

Hey guys,

I got a problem i need help trying to work something out.
I am working on this assignment but i have no idea where to start.
It is the following problem.

Make a console application that can draw lines consisting of characters.

The way to do this is to fill an 2-dimensional char array (say A) with blanks.

The problem is i have no idea how to start programming the following
----> Plotting a point at location x, y happens by the assignment A [yMax-y-1,x] = "*". <----

Is there anyone one who could point me into the right direction?

Is This A Good Question/Topic? 0

## Replies To: need help with figuring out how to plot a point at a specific location

### #2 pbl

• There is nothing you can't do with a JTable

Reputation: 8370
• Posts: 31,956
• Joined: 06-March 08

## Re: need help with figuring out how to plot a point at a specific location

Posted 05 April 2013 - 03:35 AM

Here is your array filled with space
char[][] a = new char[20][40];   // 20 row 40 columns
for(int row = 0; row < a.length; ++row) {
for(int col = 0; col < a[row].length; ++col) {
a[row][col] = ' ';
}
}

you can always do a[10][20] '*';

Happy coding

### #3 Droidx

Reputation: 0
• Posts: 2
• Joined: 05-April 13

## Re: need help with figuring out how to plot a point at a specific location

Posted 05 April 2013 - 04:14 AM

pbl, on 05 April 2013 - 03:35 AM, said:

Here is your array filled with space
char[][] a = new char[20][40];   // 20 row 40 columns
for(int row = 0; row < a.length; ++row) {
for(int col = 0; col < a[row].length; ++col) {
a[row][col] = ' ';
}
}

you can always do a[10][20] '*';

Happy coding

Hey thanks for the response.
Sorry but maybe i wasn't clear enough. Luckily i already found out how to create the array via Google.
My real question was actually concerning the plotting a point at a location:

Plotting a point at location x, y happens by the assignment A [yMax-y-1,x] = "*".

### #4 pbl

• There is nothing you can't do with a JTable

Reputation: 8370
• Posts: 31,956
• Joined: 06-March 08

## Re: need help with figuring out how to plot a point at a specific location

Posted 05 April 2013 - 06:36 AM

a[someX][someY] = 'Z';

will print a Z at someY,someY when you'll print the array... else arounf will be spaces

### #5 pbl

• There is nothing you can't do with a JTable

Reputation: 8370
• Posts: 31,956
• Joined: 06-March 08

## Re: need help with figuring out how to plot a point at a specific location

Posted 05 April 2013 - 06:43 AM

char[][] a = new char[5][7];
for(int row = 0; row < a.length; ++row) {
for(int col = 0; col < a[row].length; ++col) {
a[row][col] = ' ';
}
}
a[1][6] = '/';
a[2][5] = '/';
a[3][4] = '/';
a[4][3] = 'V';
a[3][2] = '\\';   // <--- this one is tricvkier :)/>
for(int row = 0; row < a.length; ++row) {
for(int col = 0; col < a[row].length; ++col) {
System.out.print(a[row][col]);
}
System.out.println();
}

yields

/
/
\ /
V