-
Notifications
You must be signed in to change notification settings - Fork 4
/
filesystem.py
44 lines (32 loc) · 1014 Bytes
/
filesystem.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
from abc import ABC, abstractmethod
class FileSystem(ABC):
@abstractmethod
def ls(self):
pass
class File(FileSystem):
fileName = None
def __init__(self, name):
self.fileName = name
def ls(self):
print("file name ", self.fileName)
class Directory(FileSystem):
directoryName = None
fileSystemList = None
def __init__(self, name):
self.directoryName = name
self.fileSystemList = []
def add(self, fileSystemObj):
self.fileSystemList.append(fileSystemObj)
def ls(self):
print("Directory name ", self.directoryName)
for fileSystemObj in self.fileSystemList:
fileSystemObj.ls()
if __name__ == '__main__':
movieDirectory = Directory("Movie")
border = File("Border")
movieDirectory.add(border)
comedyMovieDirectory = Directory("ComedyMovie")
hulchul = File("Hulchul")
comedyMovieDirectory.add(hulchul)
movieDirectory.add(comedyMovieDirectory)
movieDirectory.ls()