Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import turtle as tt
- print '-======================-'
- print 'Прямоугольник - RXчислоYчислоWчислоHчисло'
- print 'Окружность - CXчислоYчислоRчисло'
- print 'Многоугольник - AXчислоYчислоRчислоAчисло'
- print 'Отрезок - LXчислоYчислоUчислоVчисло'
- print '-======================-'
- line = raw_input('Введите строку, разделительный знак которой `: ')
- error = 0
- x = ''
- y = ''
- w = ''
- h = ''
- r = ''
- a = ''
- u = ''
- v = ''
- maxw = tt.window_width()
- maxh = tt.window_height()
- while len(line)>0 and error == 0:
- code = line[0]
- if code != 'R' and code != 'C' and code != 'L' and code != 'A':
- error = 1
- else:
- line = line[1:]
- if line[0] != 'X':
- error = 1
- else:
- line = line[1:]
- if line[0] == '-':
- x = x+line[0]
- line = line[1:]
- while line[0] != 'Y' and 0<=int(line[0])<=9:
- x = x+line[0]
- line = line[1:]
- if line[0] != 'Y':
- error == 1
- else:
- line = line[1:]
- if line[0] == '-':
- y = y+line[0]
- line = line[1:]
- while line[0] != 'W' and line[0] != 'R' and line[0] != 'U' and 0<=int(line[0])<=9:
- y = y+line[0]
- line = line[1:]
- if code == 'R':
- if line[0] != 'W':
- error == 1
- else:
- line = line[1:]
- if line[0] == '-':
- error == 1
- while line[0] != 'H' and 0<=int(line[0])<=9:
- w = w+line[0]
- line = line[1:]
- if line[0] != 'H':
- error = 1
- else:
- line = line[1:]
- if line[0] == '-':
- error == 1
- while len(line)>0 and 0<=int(line[0])<=9:
- h = h+line[0]
- line = line[1:]
- if (abs(int(x))+int(w)/2)>(maxw/2) or (abs(int(y))+int(h)/2)>(maxh/2):
- error == 1
- else:
- tt.reset()
- tt.up()
- tt.goto((int(x)-int(w)/2),(int(y)-int(h)/2))
- tt.down()
- tt.fd(int(w))
- tt.left(90)
- tt.forward(int(h))
- tt.left(90)
- tt.forward(int(w))
- tt.left(90)
- tt.forward(int(h))
- tt.up()
- if code == 'C':
- if line[0] != 'R':
- error == 1
- else:
- line = line[1:]
- if line[0] == '-':
- error == 1
- while len(line)>0 and 0<=int(line[0])<=9:
- r = r+line[0]
- line = line[1:]
- if (int(x)+int(r))>(maxw/2) or (int(y)+int(r))>(maxh/2):
- error == 1
- else:
- tt.reset()
- tt.up()
- tt.goto(int(x),int(y)-int(r))
- tt.down()
- tt.circle(int(r))
- tt.up()
- if code == 'A':
- if line[0] != 'R':
- error == 1
- else:
- line = line[1:]
- if line[0] == '-':
- error == 1
- else:
- while line[0] != 'A' and 0<=int(line[0])<=9:
- r = r+line[0]
- line = line[1:]
- if line[0] != 'A':
- error == 1
- else:
- line = line[1:]
- if line[0] == '-':
- error == 1
- else:
- while len(line)>0 and 0<=int(line[0])<=9:
- a = a+line[0]
- line = line[1:]
- if (int(x)+int(r))>(maxw/2) or (int(y)+int(r))>(maxh/2) or 0<=int(a)<=2:
- error == 1
- else:
- tt.reset()
- tt.up()
- tt.goto(int(x),int(y)-int(r))
- tt.down()
- tt.circle(int(r),360,int(a))
- tt.up()
- if code == 'L':
- if line[0] != 'U':
- error == 1
- else:
- line = line[1:]
- if line[0] == '-':
- u = u+line[0]
- line = line[1:]
- while line[0] != 'V' and 0<=int(line[0])<=9:
- u = u+line[0]
- line = line[1:]
- if line[0] != 'V':
- error == 1
- else:
- line = line[1:]
- if line[0] == '-':
- v = v+line[0]
- line = line[1:]
- while len(line)>0 and 0<=int(line[0])<=9:
- v = v+line[0]
- line = line[1:]
- if abs(int(u))>(maxw/2) or abs(int(v))>(maxh/2):
- error == 1
- else:
- tt.reset()
- tt.up()
- tt.goto(int(x),int(y))
- tt.down()
- tt.goto(int(u),int(v))
- tt.up()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement