diff options
author | Matthew Strapp <msattr@gmail.com> | 2019-09-24 14:00:10 -0500 |
---|---|---|
committer | Matthew Strapp <msattr@gmail.com> | 2019-09-24 14:00:10 -0500 |
commit | 657e0c3991492646b33022f7aae5638cc62d4550 (patch) | |
tree | 6503e89b4ed0589b6d9cbf4bce15e111fe6c4742 /csci1913 | |
parent | Do lab (diff) | |
parent | Format things gooder (diff) | |
download | homework-657e0c3991492646b33022f7aae5638cc62d4550.tar homework-657e0c3991492646b33022f7aae5638cc62d4550.tar.gz homework-657e0c3991492646b33022f7aae5638cc62d4550.tar.bz2 homework-657e0c3991492646b33022f7aae5638cc62d4550.tar.lz homework-657e0c3991492646b33022f7aae5638cc62d4550.tar.xz homework-657e0c3991492646b33022f7aae5638cc62d4550.tar.zst homework-657e0c3991492646b33022f7aae5638cc62d4550.zip |
Merge branch 'master' of github.com:RosstheRoss/TestingFun
Diffstat (limited to 'csci1913')
-rw-r--r-- | csci1913/Python/lab1_strap012.py (renamed from csci1913/lab1/lab1_strap012.py) | 0 | ||||
-rw-r--r-- | csci1913/Python/lab2_strap012.py (renamed from csci1913/lab1/lab2_strap012.py) | 45 |
2 files changed, 36 insertions, 9 deletions
diff --git a/csci1913/lab1/lab1_strap012.py b/csci1913/Python/lab1_strap012.py index 396fda9..396fda9 100644 --- a/csci1913/lab1/lab1_strap012.py +++ b/csci1913/Python/lab1_strap012.py diff --git a/csci1913/lab1/lab2_strap012.py b/csci1913/Python/lab2_strap012.py index 34fbe6a..4e154f7 100644 --- a/csci1913/lab1/lab2_strap012.py +++ b/csci1913/Python/lab2_strap012.py @@ -1,20 +1,47 @@ class Zillion: def __init__(self,digits): self.digits = digits - if (1==1): - try: - int(digits) - except ValueError: - raise RuntimeError + self.List = [] + self.toList() + + def toList(self): + badBoolean=False #Kludge + 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: #Non-comma character in string + raise RuntimeError + if badBoolean is False: #No numbers in string + raise RuntimeError + else: + return self.List + + def increment(self): - return int(self.digits)+1 + length = len(self.List) - 1 + newList = self.List + newList[len(self.List)-1] += 1 + if newList[length]>=10: #Loop to increment all 10s to 0s with carry + for n in range (0,length): + newList[length-n]=0 + newList[length-n-1]+=1 + 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: 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]) #Make string by concatenation + return string |