generated from emilybache/GildedRose-Refactoring-Kata
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGildedRose.pas
106 lines (95 loc) · 2.33 KB
/
GildedRose.pas
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
unit GildedRose;
interface
uses
Item,
System.Generics.Collections;
type
TGildedRose = class(TObject)
private
FItems: TObjectList<TItem>;
public
constructor Create(const AItems: TObjectList<TItem>);
procedure UpdateQuality;
property Items: TObjectList<TItem> read FItems;
end;
implementation
{ TGildedRose }
constructor TGildedRose.Create(const AItems: TObjectList<TItem>);
begin
inherited Create;
FItems := AItems;
end;
procedure TGildedRose.UpdateQuality;
var
I: Integer;
begin
for I := 0 to Items.Count - 1 do
begin
if (Items[I].Name <> 'Aged Brie') and (Items[I].Name <> 'Backstage passes to a TAFKAL80ETC concert') then
begin
if Items[I].Quality > 0 then
begin
if Items[I].Name <> 'Sulfuras, Hand of Ragnaros' then
begin
Items[I].Quality := Items[I].Quality - 1;
end;
end;
end
else
begin
if Items[I].Quality < 50 then
begin
Items[I].Quality := Items[I].Quality + 1;
if Items[I].Name = 'Backstage passes to a TAFKAL80ETC concert' then
begin
if Items[I].SellIn < 11 then
begin
if Items[I].Quality < 50 then
begin
Items[I].Quality := Items[I].Quality + 1;
end;
end;
if Items[I].SellIn < 6 then
begin
if Items[I].Quality < 50 then
begin
Items[I].Quality := Items[I].Quality + 1;
end;
end;
end;
end;
end;
if Items[I].Name <> 'Sulfuras, Hand of Ragnaros' then
begin
Items[I].SellIn := Items[I].SellIn - 1;
end;
if Items[I].SellIn < 0 then
begin
if Items[I].Name <> 'Aged Brie' then
begin
if Items[I].Name <> 'Backstage passes to a TAFKAL80ETC concert' then
begin
if Items[I].Quality > 0 then
begin
if Items[I].Name <> 'Sulfuras, Hand of Ragnaros' then
begin
Items[I].Quality := Items[I].Quality - 1;
end;
end;
end
else
begin
Items[I].Quality := Items[I].Quality - Items[I].Quality;
end;
end
else
begin
if Items[I].Quality < 50 then
begin
Items[I].Quality := Items[I].Quality + 1;
end;
end;
end;
end;
end;
end.