forked from TimSongCoder/LearnJavaForAndroid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.java
More file actions
29 lines (26 loc) · 817 Bytes
/
Copy pathGraph.java
File metadata and controls
29 lines (26 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
public class Graph{
final static int ROWS = 11;
final static int COLS = 23;
public static void main(String[] args){
char[][] screen = new char[ROWS][COLS];
for(int row=0; row<screen.length; row ++){
for(int col = 0; col<screen[0].length; col++){
screen[row][col] = ' ';
}
}
double scaleX = COLS / 360.0;
for(int degree = 0; degree<360; degree ++){
int row = ROWS/2 + (int)Math.round(ROWS/2*Math.sin(Math.toRadians(degree)));
int col = (int)(degree*scaleX);
screen[row][col] = 'S';
row = ROWS/2 + (int)Math.round(ROWS/2 * Math.cos(Math.toRadians(degree)));
screen[row][col] = screen[row][col]== 'S'? '*' : 'C';
}
for(int row = ROWS - 1; row >=0; row--){
for(int col=0; col<COLS; col++){
System.out.print(screen[row][col]);
}
System.out.println();
}
}
}