Skip to content

Commit 0321db7

Browse files
author
hussienalrubaye
committed
OOP
1 parent 8a1caa3 commit 0321db7

File tree

8 files changed

+265
-142
lines changed

8 files changed

+265
-142
lines changed

.idea/workspace.xml

Lines changed: 127 additions & 132 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OOPBasicClass.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
class Car:
3+
def GetOwner(self):
4+
print("Owner is ",self._Name)
5+
def SetOwner(self,Name):
6+
self._Name=Name
7+
8+
9+
10+
def main():
11+
mycar=Car()
12+
mycar.SetOwner("Hussein Alrubaye")
13+
mycar.GetOwner()
14+
Jencar=Car()
15+
Jencar.SetOwner("Jen Alrubaye")
16+
Jencar.GetOwner()
17+
18+
19+
20+
if __name__ == '__main__':main()

OOPInhertance.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
class Operation:
2+
def Sum(self,n1,n2):
3+
SumResult=n1+n2
4+
print("Sum=",SumResult)
5+
def Sub(self,n1,n2):
6+
SubResult=n1-n2
7+
print("Sub=",SubResult)
8+
class OperationWithMul(Operation):
9+
10+
def Mul(self,n1,n2):
11+
MulResult=n1*n2
12+
print("Mul=",MulResult)
13+
14+
15+
def main():
16+
#OP=Operation()
17+
#OP.Sub(4,2)
18+
#OP.Sum(10,15)
19+
OpMul=OperationWithMul();
20+
OpMul.Sub(4,2)
21+
OpMul.Sum(10,15)
22+
OpMul.Mul(10,2)
23+
24+
25+
26+
27+
28+
if __name__ == '__main__':main()

OOPKwarges.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
class Car:
3+
def __init__(self,**kwargs):
4+
self.Data=kwargs
5+
def GetOwner(self):
6+
print("Owner Name ",self.Data["Name"])
7+
print("Car Model ",self.Data["Model"])
8+
print("Year ",self.Data["Year"])
9+
def Set_Model(self,Model):
10+
self.Data["Model"]=Model
11+
def Get_Model(self):
12+
print("Car Model ",self.Data["Model"])
13+
14+
15+
16+
17+
def main():
18+
mycar=Car(Name="Hussein Alrubaye",Model="camer 2015",Year=2015)
19+
mycar.GetOwner()
20+
Jencar=Car(Name="Jen Alrubaye",Model="sony x",Year=2015)
21+
Jencar.GetOwner()
22+
#jen model set
23+
Jencar.Set_Model("2016")
24+
Jencar.Get_Model()
25+
26+
27+
28+
if __name__ == '__main__':main()

OOPOverride.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
class Operation:
2+
def Sum(self,n1,n2):
3+
SumResult=n1+n2
4+
print("Sum=",SumResult)
5+
def Sub(self,n1,n2):
6+
SubResult=n1-n2
7+
print("Sub=",SubResult)
8+
class OperationWithMul(Operation):
9+
10+
def Mul(self,n1,n2):
11+
MulResult=n1*n2
12+
print("Mul=",MulResult)
13+
def Sub(self,n1,n2):
14+
super().Sub(n1,n2)
15+
#SubResult=n1-n2+5
16+
#print("Sub=",SubResult)
17+
18+
19+
def main():
20+
#OP=Operation()
21+
#OP.Sub(4,2)
22+
#OP.Sum(10,15)
23+
OpMul=OperationWithMul();
24+
OpMul.Sub(4,2)
25+
OpMul.Sum(10,15)
26+
OpMul.Mul(10,2)
27+
28+
29+
30+
31+
32+
if __name__ == '__main__':main()

OOPconstructors.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
class Car:
3+
def __init__(self,Name):
4+
self._Name=Name
5+
def GetOwner(self):
6+
print("Owner is ",self._Name)
7+
8+
9+
10+
11+
def main():
12+
mycar=Car("Hussein Alrubaye")
13+
mycar.GetOwner()
14+
Jencar=Car("Jen Alrubaye")
15+
Jencar.GetOwner()
16+
17+
18+
19+
if __name__ == '__main__':main()

main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ def main():
88

99

1010

11+
1112
if __name__ == '__main__':main()

snaped.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
x=1
2-
x="hi" if x==1 else "why"
3-
fo = open("foo.txt", "a") #r write a append
4-
fo.write( "Python is a great language.\nYeah its great!!\n")
5-
fo.close()
6-
r = open("foo.txt", "r")
7-
# read=r.read(102033)
8-
for s in r:
9-
print(s)
10-
r.close()
1+
db=sqlite3.connect("test.db")
2+
db.row_factory = sqlite3.Row
3+
db.execute("create table if not exists Admin(name text,age int)")
4+
db.execute("insert into Admin (name,age) values (?, ?)",("hussein",27))
5+
#db.execute('insert into Admin (name, age) values (?, ?)', (row['t1'], row['i1']))
6+
print("hello from python")
7+
print("next line execute")
8+
cursor=db.execute("select * from Admin")
9+
for row in cursor:
10+
print(' {}: {}'.format(row['name'], row['age']))

0 commit comments

Comments
 (0)