From a1c705c5b3024984740138b463553f84edfa0b0b Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Mon, 23 Sep 2019 13:03:05 -0500 Subject: Final stretches of a bad mess --- csci1913/lab1/lab2_strap012.py | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/csci1913/lab1/lab2_strap012.py b/csci1913/lab1/lab2_strap012.py index 50db0ea..1a9b601 100644 --- a/csci1913/lab1/lab2_strap012.py +++ b/csci1913/lab1/lab2_strap012.py @@ -2,23 +2,37 @@ class Zillion: def __init__(self,digits): self.digits = digits self.__x=0 - if digits is not '': - for __x in range (0,len(digits)): - try: - int(digits[__x]) - except ValueError: - raise RuntimeError - else: + self.List = [] + self.toList() + def toList(self): + badBoolean=False + if len(self.digits) == 0: + raise RuntimeError #Cannot make a list of nothing + for n in range (0,len(self.digits)): + if self.digits[n] is not ',': + if self.digits[n] is not ' ': + try: + self.List+=[int(self.digits[n])] + badBoolean=True + except ValueError: + raise RuntimeError + if badBoolean is False: raise RuntimeError + else: + return self.List def increment(self): - return int(self.digits)+1 + return None def isZero(self): - for n in range (0,len(self.digits)): - if str(self.digits)[n] is not '0': + for p in range (0,len(self.List)-1): + if self.List[p] is not 0 or not '0': return False return True def toString(self): - return str(self.digits) + string='' + for q in range (0,len(self.List)): + string+=str(self.List[q]) + return string + -- cgit v1.2.3