diff options
Diffstat (limited to '')
| -rw-r--r-- | csci1913/lab1/lab2_strap012.py | 36 | 
1 files 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 + | 
