-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTIGr.py
71 lines (53 loc) · 1.33 KB
/
TIGr.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from abc import ABC, abstractmethod
"""
Tiny Interpreted Graphic = TIGr
Keep the interfaces defined below in your work.
"""
class AbstractDrawer(ABC):
""" Responsible for defining an interface for drawing """
@abstractmethod
def select_pen(self, pen_num):
pass
@abstractmethod
def pen_down(self):
pass
@abstractmethod
def pen_up(self):
pass
@abstractmethod
def go_along(self, along):
pass
@abstractmethod
def go_down(self, down):
pass
@abstractmethod
def draw_line(self, direction, distance):
pass
class AbstractParser(ABC):
def __init__(self, drawer):
self.drawer = drawer
self.source = []
self.command = ''
self.data = 0
@abstractmethod
def parse(self, raw_source):
pass
class AbstractInterface(ABC):
"""
Responsible for providing source text for parsing and drawing
Initiates the Draw use-case.
Links to a parser and passes the source text onwards
"""
def __init__(self, parser):
self.parser = parser
self.interface = None
self.config = None
@abstractmethod
def create_interface(self):
pass
@abstractmethod
def open_config(self):
pass
@abstractmethod
def go(self):
pass