'Bringing back python files;'
This commit is contained in:
parent
68b370241f
commit
df53ebf85b
17
python/.project
Normal file
17
python/.project
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>wmii-prog-obiektowe-python</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.python.pydev.PyDevBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.python.pydev.pythonNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
8
python/.pydevproject
Normal file
8
python/.pydevproject
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<?eclipse-pydev version="1.0"?><pydev_project>
|
||||||
|
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
|
||||||
|
<path>/${PROJECT_DIR_NAME}</path>
|
||||||
|
</pydev_pathproperty>
|
||||||
|
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property>
|
||||||
|
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
|
||||||
|
</pydev_project>
|
0
python/net/__init__.py
Normal file
0
python/net/__init__.py
Normal file
18
python/net/hypki/Area.py
Normal file
18
python/net/hypki/Area.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
'''
|
||||||
|
Created on Apr 4, 2023
|
||||||
|
|
||||||
|
@author: ahypki
|
||||||
|
'''
|
||||||
|
|
||||||
|
class Area():
|
||||||
|
'''
|
||||||
|
classdocs
|
||||||
|
'''
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
'''
|
||||||
|
Constructor
|
||||||
|
'''
|
||||||
|
|
||||||
|
def compute_area(self):
|
||||||
|
pass
|
27
python/net/hypki/Figure.py
Normal file
27
python/net/hypki/Figure.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
'''
|
||||||
|
Created on Apr 4, 2023
|
||||||
|
|
||||||
|
@author: ahypki
|
||||||
|
'''
|
||||||
|
|
||||||
|
class Figure():
|
||||||
|
'''
|
||||||
|
classdocs
|
||||||
|
'''
|
||||||
|
|
||||||
|
__name = '';
|
||||||
|
|
||||||
|
def __init__(self, newName = 'Default __name'):
|
||||||
|
'''
|
||||||
|
Constructor
|
||||||
|
'''
|
||||||
|
self.__name = newName;
|
||||||
|
|
||||||
|
def get_name(self):
|
||||||
|
return self.__name
|
||||||
|
|
||||||
|
def set_name(self, value):
|
||||||
|
self.__name = value
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "Figure with name= {0}".format(self.__name)
|
33
python/net/hypki/Main.py
Normal file
33
python/net/hypki/Main.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
'''
|
||||||
|
Created on Apr 4, 2023
|
||||||
|
|
||||||
|
@author: ahypki
|
||||||
|
'''
|
||||||
|
from net.hypki.Figure import Figure
|
||||||
|
from net.hypki.Square import Square
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
f = Figure()
|
||||||
|
f.__name = "New name"
|
||||||
|
|
||||||
|
f2 = Figure('Another name')
|
||||||
|
|
||||||
|
print(str(f))
|
||||||
|
print(str(f2))
|
||||||
|
|
||||||
|
s1 = Square('Square1')
|
||||||
|
print(str(s1))
|
||||||
|
# print(str(s1.__name)) # will not work
|
||||||
|
print(s1.get_name())
|
||||||
|
|
||||||
|
# generics... actually are not needed - duck typing
|
||||||
|
figList = [Figure('f1'), Figure('f2')]
|
||||||
|
print(figList)
|
||||||
|
print(*figList) # uses our __str__ function
|
||||||
|
|
||||||
|
figList = [Square('s1'), Square('s2')]
|
||||||
|
print(figList)
|
||||||
|
print(*figList) # uses our __str__ function
|
||||||
|
print(figList[0].get_name()) # but there is no help from IDE
|
||||||
|
|
||||||
|
print('Finished!')
|
24
python/net/hypki/Square.py
Normal file
24
python/net/hypki/Square.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
'''
|
||||||
|
Created on Apr 4, 2023
|
||||||
|
|
||||||
|
@author: ahypki
|
||||||
|
'''
|
||||||
|
from net.hypki.Figure import Figure
|
||||||
|
from net.hypki.Area import Area
|
||||||
|
|
||||||
|
class Square(Figure, Area):
|
||||||
|
'''
|
||||||
|
classdocs
|
||||||
|
'''
|
||||||
|
|
||||||
|
def __init__(self, newName):
|
||||||
|
'''
|
||||||
|
Constructor
|
||||||
|
'''
|
||||||
|
super().__init__(newName)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "Square with name= {0} has area= {1}".format(self.get_name(), self.compute_area())
|
||||||
|
|
||||||
|
def compute_area(self):
|
||||||
|
return 4.0
|
0
python/net/hypki/__init__.py
Normal file
0
python/net/hypki/__init__.py
Normal file
Loading…
Reference in New Issue
Block a user