File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 66#printString: to print the string in upper case.
77#Also please include simple test function to test the class methods.
88
9+ # Create a class named StringHandling
910class StringHandling (object ):
11+ # The init will initialize a string variable in the class
1012 def __init__ (self ):
1113 self .string = ""
14+ # getString(self) will read the input from the user
1215 def getString (self ):
1316 print "Enter a string:"
1417 self .string = raw_input ()
18+ # printString(self) will print the string in uppercase
1519 def printString (self ):
1620 print self .string .upper ()
1721
18- def test (StringHandling ):
19- testingClass = StringHandling
22+ # Define a test method that expects a StringHandling class type
23+ def test (testingClass ):
24+ # Call the getString method
2025 testingClass .getString ()
26+ # Call the printString method
2127 testingClass .printString ()
2228
29+ # Create a test object called testObject
2330testObject = StringHandling ()
31+ # Test the testObject with the test method
2432test (testObject )
You can’t perform that action at this time.
0 commit comments