Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.62 KB | None | 0 0
  1. import turtle as tt
  2.  
  3. print '-======================-'
  4. print 'Прямоугольник - RXчислоYчислоWчислоHчисло'
  5. print 'Окружность - CXчислоYчислоRчисло'
  6. print 'Многоугольник - AXчислоYчислоRчислоAчисло'
  7. print 'Отрезок - LXчислоYчислоUчислоVчисло'
  8. print '-======================-'
  9.  
  10. line = raw_input('Введите строку, разделительный знак которой `: ')
  11. error = 0
  12. x = ''
  13. y = ''
  14. w = ''
  15. h = ''
  16. r = ''
  17. a = ''
  18. u = ''
  19. v = ''
  20. maxw = tt.window_width()
  21. maxh = tt.window_height()
  22. while len(line)>0 and error == 0:
  23.     code = line[0]
  24.     if code != 'R' and code != 'C' and code != 'L' and code != 'A':
  25.         error = 1
  26.     else:
  27.         line = line[1:]
  28.         if line[0] != 'X':
  29.             error = 1
  30.         else:
  31.             line = line[1:]
  32.             if line[0] == '-':
  33.                 x = x+line[0]
  34.                 line = line[1:]
  35.             while line[0] != 'Y' and 0<=int(line[0])<=9:
  36.                 x = x+line[0]
  37.                 line = line[1:]
  38.             if line[0] != 'Y':
  39.                 error == 1
  40.             else:
  41.                 line = line[1:]
  42.                 if line[0] == '-':
  43.                     y = y+line[0]
  44.                     line = line[1:]
  45.                 while line[0] != 'W' and line[0] != 'R' and 0<=int(line[0])<=9:
  46.                     y = y+line[0]
  47.                     line = line[1:]
  48.                 if code == 'R':
  49.                     if line[0] != 'W':
  50.                         error == 1
  51.                     else:
  52.                         line = line[1:]
  53.                         if line[0] == '-':
  54.                             error == 1
  55.                         while line[0] != 'H' and 0<=int(line[0])<=9:
  56.                             w = w+line[0]
  57.                             line = line[1:]
  58.                         if line[0] != 'H':
  59.                             error = 1
  60.                         else:
  61.                             line = line[1:]
  62.                             if line[0] == '-':
  63.                                 error == 1
  64.                             while len(line)>0 and 0<=int(line[0])<=9:
  65.                                 h = h+line[0]
  66.                                 line = line[1:]
  67.                             if (abs(int(x))+int(w)/2)>(maxw/2) or (abs(int(y))+int(h)/2)>(maxh/2):
  68.                                 error == 1
  69.                             else:
  70.                                 tt.reset()
  71.                                 tt.up()
  72.                                 tt.goto((int(x)-int(w)/2),(int(y)-int(h)/2))
  73.                                 tt.down()
  74.                                 tt.fd(int(w))
  75.                                 tt.left(90)
  76.                                 tt.forward(int(h))
  77.                                 tt.left(90)
  78.                                 tt.forward(int(w))
  79.                                 tt.left(90)
  80.                                 tt.forward(int(h))
  81.                                 tt.up()
  82.                
  83.                 if code == 'C':
  84.                     if line[0] != 'R':
  85.                         error == 1
  86.                     else:
  87.                         line = line[1:]
  88.                         if line[0] == '-':
  89.                             error == 1
  90.                         while len(line)>0 and 0<=int(line[0])<=9:
  91.                             r = r+line[0]
  92.                             line = line[1:]
  93.                         if (int(x)+int(r))>(maxw/2) or (int(y)+int(r))>(maxh/2):
  94.                             error == 1
  95.                         else:
  96.                             tt.reset()
  97.                             tt.up()
  98.                             tt.goto(int(x),int(y)-int(r))
  99.                             tt.down()
  100.                             tt.circle(int(r))
  101.                             tt.up()
  102.                 if code == 'A':
  103.                     if line[0] != 'R':
  104.                         error == 1
  105.                     else:
  106.                         line = line[1:]
  107.                         if line[0] == '-':
  108.                             error == 1
  109.                         else:
  110.                             while line[0] != 'A' and 0<=int(line[0])<=9:
  111.                                 r = r+line[0]
  112.                                 line = line[1:]
  113.                             if line[0] != 'A':
  114.                                 error == 1
  115.                             else:
  116.                                 line = line[1:]
  117.                                 if line[0] == '-':
  118.                                     error == 1
  119.                                 else:
  120.                                     while len(line)>0  and 0<=int(line[0])<=9:
  121.                                         a = a+line[0]
  122.                                         line = line[1:]
  123.                                     if (int(x)+int(r))>(maxw/2) or (int(y)+int(r))>(maxh/2) or 0<=int(a)<=2:
  124.                                         error == 1
  125.                                     else:
  126.                                         tt.reset()
  127.                                         tt.up()
  128.                                         tt.goto(int(x),int(y)-int(r))
  129.                                         tt.down()
  130.                                         tt.circle(int(r),360,int(a))
  131.                                         tt.up()
  132.                 if code == 'L':
  133.                     if line[0] != 'U':
  134.                         error == 1
  135.                     else:
  136.                         line = line[1:]
  137.                         if line[0] == '-':
  138.                             u = u+line[0]
  139.                         while line[0] != 'V' and 0<=int(line[0])<=9:
  140.                             u = u+line[0]
  141.                             line = line[1:]
  142.                         if line[0] != 'V':
  143.                             error == 1
  144.                         else:
  145.                             line = line[1:]
  146.                             if line[0] == '-':
  147.                                 v = v+line[0]
  148.                             while len(line)>0  and 0<=int(line[0])<=9:
  149.                                 v = v+line[0]
  150.                                 line = line[1:]
  151.                                 if abs(int(u))>(maxw/2) or abs(int(v))>(maxh/2):
  152.                                     error == 1
  153.                                 else:
  154.                                     tt.reset()
  155.                                     tt.up()
  156.                                     tt.goto(int(x),int(y))
  157.                                     tt.down()
  158.                                     tt.goto(int(u),int(v))
  159.                                     tt.up()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement