Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GildedRose Refactoring Kata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirio Eggmann
GildedRose Refactoring Kata
Commits
814e49aa
Verified
Commit
814e49aa
authored
2 years ago
by
Mirio Eggmann
Browse files
Options
Downloads
Patches
Plain Diff
refactor
parent
0d1e3eb0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Java/src/main/java/com/gildedrose/GildedRose.java
+51
-46
51 additions, 46 deletions
Java/src/main/java/com/gildedrose/GildedRose.java
with
51 additions
and
46 deletions
Java/src/main/java/com/gildedrose/GildedRose.java
+
51
−
46
View file @
814e49aa
...
...
@@ -3,60 +3,65 @@ package com.gildedrose;
class
GildedRose
{
Item
[]
items
;
private
static
final
String
BACKSTAGE_PASSES
=
"Backstage passes to a TAFKAL80ETC concert"
;
private
static
final
String
SULFURAS
=
"Sulfuras, Hand of Ragnaros"
;
private
static
final
String
AGED_BRIE
=
"Aged Brie"
;
public
GildedRose
(
Item
[]
items
)
{
this
.
items
=
items
;
}
public
void
updateQuality
()
{
for
(
int
i
=
0
;
i
<
items
.
length
;
i
++)
{
if
(!
items
[
i
].
name
.
equals
(
"Aged Brie"
)
&&
!
items
[
i
].
name
.
equals
(
"Backstage passes to a TAFKAL80ETC concert"
))
{
if
(
items
[
i
].
quality
>
0
)
{
if
(!
items
[
i
].
name
.
equals
(
"Sulfuras, Hand of Ragnaros"
))
{
items
[
i
].
quality
=
items
[
i
].
quality
-
1
;
}
}
}
else
{
if
(
items
[
i
].
quality
<
50
)
{
items
[
i
].
quality
=
items
[
i
].
quality
+
1
;
if
(
items
[
i
].
name
.
equals
(
"Backstage passes to a TAFKAL80ETC concert"
))
{
if
(
items
[
i
].
sellIn
<
11
)
{
if
(
items
[
i
].
quality
<
50
)
{
items
[
i
].
quality
=
items
[
i
].
quality
+
1
;
}
}
if
(
items
[
i
].
sellIn
<
6
)
{
if
(
items
[
i
].
quality
<
50
)
{
items
[
i
].
quality
=
items
[
i
].
quality
+
1
;
}
}
}
}
for
(
Item
item
:
items
)
{
if
(
item
.
name
.
equals
(
AGED_BRIE
))
{
updateQualityAgedBrie
(
item
);
}
else
if
(
item
.
name
.
equals
(
BACKSTAGE_PASSES
))
{
updateQualityBackstagePasses
(
item
);
}
else
if
(!
item
.
name
.
equals
(
SULFURAS
))
{
updateQualityOtherItems
(
item
);
}
}
}
if
(!
items
[
i
].
name
.
equals
(
"Sulfuras, Hand of Ragnaros"
))
{
items
[
i
].
sellIn
=
items
[
i
].
sellIn
-
1
;
}
private
void
updateQualityAgedBrie
(
Item
item
)
{
if
(
item
.
quality
<
50
)
{
item
.
quality
++;
}
if
(
item
.
sellIn
<
0
&&
item
.
quality
<
50
)
{
item
.
quality
++;
}
updateSellIn
(
item
);
}
if
(
items
[
i
].
sellIn
<
0
)
{
if
(!
items
[
i
].
name
.
equals
(
"Aged Brie"
))
{
if
(!
items
[
i
].
name
.
equals
(
"Backstage passes to a TAFKAL80ETC concert"
))
{
if
(
items
[
i
].
quality
>
0
)
{
if
(!
items
[
i
].
name
.
equals
(
"Sulfuras, Hand of Ragnaros"
))
{
items
[
i
].
quality
=
items
[
i
].
quality
-
1
;
}
}
}
else
{
items
[
i
].
quality
=
items
[
i
].
quality
-
items
[
i
].
quality
;
}
}
else
{
if
(
items
[
i
].
quality
<
50
)
{
items
[
i
].
quality
=
items
[
i
].
quality
+
1
;
}
}
private
void
updateQualityBackstagePasses
(
Item
item
)
{
if
(
item
.
quality
<
50
)
{
item
.
quality
++;
if
(
item
.
sellIn
<
11
&&
item
.
quality
<
50
)
{
item
.
quality
++;
}
if
(
item
.
sellIn
<
6
&&
item
.
quality
<
50
)
{
item
.
quality
++;
}
}
updateSellIn
(
item
);
if
(
item
.
sellIn
<
0
)
{
item
.
quality
=
0
;
}
}
private
void
updateQualityOtherItems
(
Item
item
)
{
if
(
item
.
quality
>
0
)
{
item
.
quality
--;
}
updateSellIn
(
item
);
if
(
item
.
sellIn
<
0
&&
item
.
quality
>
0
)
{
item
.
quality
--;
}
}
private
void
updateSellIn
(
Item
item
)
{
if
(!
item
.
name
.
equals
(
SULFURAS
))
{
item
.
sellIn
--;
}
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment