Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
90fa856
added reason for creating file
johnwachter Jan 20, 2019
3685ed9
moving mailroom.py to proper folder
johnwachter Jan 20, 2019
33619b1
added 3 homework files
johnwachter Jan 21, 2019
52bf499
running 'assert' tests to ensure the three functions work properly
johnwachter Jan 22, 2019
dbbef7a
changed the 'assert' test on the lucas function from lucas(0) == 2 to…
johnwachter Jan 22, 2019
611c230
adding verbose comments to describe tests
johnwachter Jan 22, 2019
f449b1e
four more python pushups down!
johnwachter Jan 22, 2019
e852c4a
Create function to swap the first and last items in a string
johnwachter Jan 26, 2019
ccb3e69
running assert tests to make sure functions work
johnwachter Jan 26, 2019
3eedf61
changing some inputs from strings to tuples to make sure the function…
johnwachter Jan 26, 2019
af1b2ca
updated first function with a try except error to allow for a tuple o…
johnwachter Jan 26, 2019
46d3846
completed series 1
johnwachter Jan 26, 2019
396bc8c
completed series 2
johnwachter Jan 27, 2019
b47b947
Completed series 4. Used for loop to iterate through original list an…
johnwachter Jan 27, 2019
5a993f0
completed
johnwachter Jan 29, 2019
64eda8b
Created file and finished exercises
johnwachter Jan 29, 2019
9bb7dfd
Built Donor database
johnwachter Jan 29, 2019
ff325e1
Changing donor database from a list of lists to a dictionary of key:v…
johnwachter Jan 29, 2019
84c5f7d
importing collections so I can have a ordered dictionary. I need an o…
johnwachter Jan 29, 2019
38eabfa
Realized ordered dictionary is not necessary. no longer importing, an…
johnwachter Jan 29, 2019
5e23522
Added while loop to repeat questions in the 'sendthankyou' function. …
johnwachter Jan 30, 2019
f6f1862
want to make sure most up to date copy is on github
johnwachter Jan 30, 2019
f384ea3
Forced lists into sets and checked if sets were subsets, which is wor…
johnwachter Feb 1, 2019
137b87e
Printed union and intersection of sets. Can't figure out what I'm sup…
johnwachter Feb 1, 2019
b132205
Dictionaried up my mailroom
johnwachter Feb 2, 2019
ab0a34f
adding donor history to the generated letters
johnwachter Feb 2, 2019
3e9e137
built function to create trigrams from a list
johnwachter Feb 4, 2019
0b2abf4
mixed words iterating through the dict, appending to a new list, and …
johnwachter Feb 4, 2019
7f5fe9b
two more pushups
johnwachter Feb 11, 2019
8294d0d
First Commit
johnwachter Feb 16, 2019
f46f77b
changing report function
johnwachter Feb 16, 2019
04cd604
split the thank you letter text and the file creation functions into …
johnwachter Feb 16, 2019
a4cd2fc
created two helper functions and put them inside the sendthankyou fun…
johnwachter Feb 17, 2019
5ea7a06
created another helper function to create the list of donors, and now…
johnwachter Feb 17, 2019
c303230
added test to check if the function creates the files it is supposed to
johnwachter Feb 17, 2019
ecc831d
added test to check if the adddonation function properly adds a new d…
johnwachter Feb 17, 2019
a4e419c
adding multiple tests to check the donorlist function which should re…
johnwachter Feb 17, 2019
ac073ab
4 more pushup exercises
johnwachter Mar 3, 2019
baf4dcc
data model is working, so committing to github as a backup
johnwachter Mar 10, 2019
86aa956
data processor is working so adding to github as a backup
johnwachter Mar 10, 2019
cdc6e24
committing session 5
johnwachter Aug 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions students/johnwachter/Final_Project/DataModel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
from datetime import datetime
import re as rex

class Product(object):
def __init__(self, product_id: int, product_name: str):
self.__product_id = product_id
self.__product_name = product_name
def __str__(self):
return("ProductID: {}, ProductName: {}".format(self.__product_id, self.__product_name))
def __repr__(self):
return "{i}:[{brk1}{pi}{p}, {c}:{cv}{brk2}]".format(brk1='{', i="Product",
pi="'ProductID':",
p=self.__product_id,
c="'ProductName'",
cv=self.__product_name, brk2='}')
def __dict__(self):
return {"ProductID": self.__product_id, "ProductName": self.__product_name}
@property
def product_id(self):
return self.__product_id
def set_product_id(self, product_id):
if type(product_id) is not int:
raise TypeError("Requires integer!")
if product_id <= 0:
raise ValueError("Requires value greater than zero!")
else:
self.__product_id = product_id
@property
def product_name(self):
return self.__product_name
def set_product_name(self, product_name):
self.__product_name = str(product_name).strip()

class InventoryCount(object):
def __init__(self, product: Product, count: int):
self.__product = product
self.__count = count
def __str__(self):
return ("Product: ({}), Number of products: {}".format(self.__product, self.__count))
def __repr__(self):
return "{i}:[{p}, {c}:{cv}]".format(i="InventoryCount",
p=self.product.__repr__(),
c="count",
cv=self.count)
def __dict__(self):
return {"Product": self.__product, "Count": self.__count}
@property
def product(self):
return self.__product
def set_product(self, product):
if type(product) is not Product: raise TypeError("Requires Product Object!")
else:
self.__product = product
@property
def count(self):
return self.__count
def set_count(self, count):
if count < 0:
raise ValueError("Negative counts are not possible")
self.__count = count

class Inventory(object):
def __init__(self, inventory_id: int, inventory_date: datetime.date, inventory_counts: InventoryCount = [None]):
self.__inventory_id = inventory_id
self.__inventory_date = inventory_date
self.__inventory_counts = inventory_counts
def __str__(self):
return("InventoryID: {}, InventoryDate: {}, InventoryCount: {}".format(self.__inventory_id, self.__inventory_date, self.__inventory_counts))
def __repr__(self):
return "{d}, {i}:[{p}, {c}:{cv}]".format(d=self.__inventory_date,
i="InventoryID",
p=self.__inventory_id.__repr__(),
c="count",
cv=self.__inventory_counts.__repr__())
def __dict__(self):
return {"InventoryID": self.__inventory_id, "InventoryDate": self.__InventoryDate, "InventoryCount": self.__inventory_counts}
@property
def inventory_id(self):
return self.__inventory_id
def set_inventory_id(self, inventory_id):
if inventory_id < 0:
raise TypeError("Can't have a negative InventoryID!")
else:
self.__inventory_id = inventory_id
@property
def inventory_date(self):
return self.__inventory_date
def set_inventory_date(self, inventory_date):
try:
if rex.match("\d\d\d\d-\d\d-\d\d", str(inventory_date)) is None:
raise TypeError("Not a Date! Use the following format: YYYY-MM-DD")
else:
self.__inventory_date = inventory_date
except Exception as e:
raise e
@property
def inventory_counts(self):
return self.__inventory_counts
def set_inventory_counts(self, inventory_counts):
if inventory_counts is not None and type(inventory_counts) is InventoryCount:
self.inventory_counts = inventory_counts

if __name__ == '__main__':
p1 = Product(100, "ProdA")
p2 = Product(200, "ProdB")
#print("P1 str function produces:\n{}".format(p1))
#print(p2.product_id)
#print(repr(p1))
p2.set_product_id(1)
#print(p2.product_id)
ic1 = InventoryCount(p1, 15)
ic2 = InventoryCount(p2, 45)
#print(repr(ic1))
#print("ic1 str function produces:\n{}".format(ic1))
invJan0119 = Inventory(1, '2019-01-01', [ic1,ic2])
invFeb0119 = Inventory(2, '2020-01-01', [ic1])
print("repr func produces: {}".format(repr(invFeb0119)))
print("Str func produces: {}".format(invFeb0119))
print("repr func produces: {}".format(repr(invJan0119)))
print("Str func produces: {}".format(invJan0119))
#for ic in invJan0119.inventory_counts:
#print(invJan0119.inventory_date , ic.product.product_name, ' = ', ic.count)
invJan0119.set_inventory_date('2019-09-01')
#print(invJan0119.inventory_date)
print(dict())

Loading