Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 053f26b

Browse files
Re-visited this topic - naming convention and made more readable
1 parent 867e4a9 commit 053f26b

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed
Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
# author = _'Sanjay'
22

3-
class A(object):
3+
class SampleClass(object):
44

5+
# for name sake, I've defined a default constructor.
56
def __init__(self):
67
pass
8+
9+
def add(self, firstNum, secondNum):
10+
'''
11+
@name: add
12+
@param: firstNum, secondNum
13+
@desc: Takes two input paramter, adding them and returning
14+
@return: sum(firstNum, secondNum)
15+
'''
16+
return self.firstNum + self.secondNum
717

8-
def add(self, a, b):
9-
print self.a + self.b
10-
11-
def add(self, a, b, c):
12-
print a + b + c
18+
19+
# this method does the same as above, but the difference is, it takes 3 parameter here.
20+
def add(self, firstNum, secondNum, thirdNum):
21+
'''
22+
@name : add
23+
@param: firstNum, secondNum, thirdNum
24+
@desc: takes three input parameter, adding them and returning
25+
@return : sum(firstNum, secondNum, threeNum)
26+
'''
27+
return self.firstNum + self.secondNum + self.thirdNum
1328

1429
#Method overloading is not possible
1530
# This is compile time polymorphism.
16-
x = A()
31+
x = SampleClass()
1732
x.add(1,2,3)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /