File tree Expand file tree Collapse file tree 2 files changed +33
-10
lines changed
Expand file tree Collapse file tree 2 files changed +33
-10
lines changed Original file line number Diff line number Diff line change @@ -139,19 +139,28 @@ Hints:
139139Use __init__ method to construct some parameters
140140
141141Solution:
142- class InputOutString(object):
143- def __init__(self):
144- self.s = ""
142+ class UpperCase:
143+
144+ def __init__(self, text):
145+ self._text = text
146+
147+ def text(self):
148+ return self._text
149+
150+ def upper(self):
151+ print(self._text.upper())
145152
146- def getString (self):
147- self.s = raw_input( )
153+ def output (self):
154+ print( self._text )
148155
149- def printString(self):
150- print self.s.upper()
156+ To access these methods from the REPL :
157+ >>> from foo import *
158+ >>> u = UpperCase("this is your text")
159+ >>> u.output()
160+ >>> this is your text
161+ >>> u.upper()
162+ >>> THIS IS YOUR TEXT
151163
152- strObj = InputOutString()
153- strObj.getString()
154- strObj.printString()
155164#----------------------------------------#
156165
157166#----------------------------------------#
Original file line number Diff line number Diff line change 1+ __author__ = 'Eoghan'
2+
3+ class UpperCase :
4+
5+ def __init__ (self , text ):
6+ self ._text = text
7+
8+ def upper (self ):
9+ print (self ._text .upper ())
10+
11+ def output (self ):
12+ print (self ._text )
13+
14+
You can’t perform that action at this time.
0 commit comments