Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class polygon{
- public static void main(String args[]){
- int count = StdIn.readInt ();
- StdIn.readLine ();
- char str [] = new char [ count ];
- for ( int i = 0; i < count ; i ++){
- str [i] = StdIn.readChar ();
- }
- StdIn.readLine ();
- StdDraw.setPenRadius(.01);
- StdDraw.setXscale(-count,count);
- StdDraw.setYscale(-count,count);
- double x1=0.0,y1=0.0;
- int ausrichtung=0;
- for (int k=0; k<count ; k++){
- if (str[k]=='F'){
- if ((ausrichtung)%4==0){
- StdDraw.line(x1,y1,x1+1,y1);
- x1=x1+1;
- y1=y1;
- }
- if ((ausrichtung)%4==1){
- StdDraw.line(x1,y1,x1,y1+1);
- x1=x1;
- y1=y1+1;
- }
- if ((ausrichtung)%4==2){
- StdDraw.line(x1,y1,x1-1,y1);
- x1=x1-1;
- y1=y1;
- }
- if ((ausrichtung)%4==3){
- StdDraw.line(x1,y1,x1,y1-1);
- x1=x1;
- y1=y1-1;
- }
- }
- if (str[k]=='R'){
- ausrichtung--;
- }
- if (str[k]=='L'){
- ausrichtung++;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment