-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathford.py
More file actions
96 lines (79 loc) · 1.61 KB
/
ford.py
File metadata and controls
96 lines (79 loc) · 1.61 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import abc
__author__= 'Bruno'
class Iterator:
"""
Iterator class
"""
__metaclass__ = abc.ABCMeta
def first(self):
"""
Return first element
"""
raise NotImplementedError
def hasNext(self):
"""
Verify if there is a next element
"""
raise NotImplementedError
def next(self):
"""
Return the next element
"""
raise NotImplementedError
class FabricIterator:
"""
Fabric's Iterator class
"""
def __init__(self, cars):
"""
Constructor
"""
self.cars = cars
self.index = 0;
def first(self):
"""
Return the first car
"""
self.index=0;
return self.cars[0]
def hasNext(self):
"""
Verifiy if there is another car
"""
return self.index < len(self.cars)
def next(self):
"""
Return the next car
"""
car = self.cars[self.index]
self.index += 1
return car
class Fabric:
"""
Fabric class
"""
def __init__(self):
"""
Constructor
"""
self.cars = []
def getIterator(self):
"""
Return the fabric iterator
"""
return FabricIterator(self.cars)
class Car:
"""
Car class
"""
def __init__(self,name="", color=""):
"""
Construcor
"""
self.name = name
self.color = color
def __str__(self):
"""
Override
"""
return "Car -> Name: {}, Color: {}".format(self.name,self.color)