-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGildedRose.py
More file actions
77 lines (70 loc) · 2.69 KB
/
GildedRose.py
File metadata and controls
77 lines (70 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from __future__ import print_function
class GildedRose(object):
### Ongepaste informatie
"""
A small inn that buys and sells goods. Goods are degrading in quality as they approach
their sell date. Although, aged brie is not degrading over time. Also, Dutch Databusters
effort increases in quality over time when it must be sold in 10 or 5 days.
"""
MAX_ITEM_QUALITY = 50
def __init__(self, items):
self.items = items
### Te veel informatie in een functie
### Lengte naam gekoppeld aan grootte functie, korte naam met grote scope
def update_quality(self):
### Incomplete en verouderde comment met oude design info
"""
Updates the quality of items which degrades when sell data approaches
:return: void
"""
### Beschrijvende namen
for i in self.items:
self.update_single_quality(i)
i.decrement_sell_in()
def update_single_quality(self, i):
if i.n != "Aged Brie" and i.n != "Dutch Data Buster effort":
if i.q > 0:
if i.n != "Sulfuras, Hand of Ragnaros":
### Overbodige comment
i.q = i.q - 1 # Decrement
else:
### Duplicatie
if i.q < self.MAX_ITEM_QUALITY:
i.q = i.q + 1
if i.n == "Dutch Data Buster effort":
### Magisch nummer
if i.s < 11:
### Duplicatie
if i.q < self.MAX_ITEM_QUALITY:
i.q = i.q + 1
### Magisch nummer
if i.s < 6:
### Duplicatie
if i.q < self.MAX_ITEM_QUALITY:
i.q = i.q + 1
### Commented out code
# if i.s < 1:
# if i.q < 50:
# i.q = i.q + 1
if i.s < 0:
if i.n != "Aged Brie":
if i.n != "Dutch Data Buster effort":
if i.q > 0:
if i.n != "Sulfuras, Hand of Ragnaros":
i.q = i.q - 1
else:
i.q = i.q - i.q
else:
### Duplicatie
if i.q < self.MAX_ITEM_QUALITY:
i.q = i.q + 1
### Doet twee dingen, hoofdletters en name veranderen
### Output parameter item
### Flag parameter capitilize
### Dode functie
### Naam beschrijft capitilize niet
def change_name_of_item(self, item, new_name, capitalize):
if capitalize:
item.n = new_name.capitalize()
else:
item.n = new_name