Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
李楚霏
/
refactorTest
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
85e441bf
authored
May 16, 2020
by
李楚霏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
task-5-magic-strings
parent
2f6ab9a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
53 deletions
+107
-53
gildedRose/src/gilded-rose.js
+57
-53
gildedRose/src/item.js
+50
-0
No files found.
gildedRose/src/gilded-rose.js
View file @
85e441bf
...
...
@@ -5,61 +5,65 @@ export class GildedRose {
this
.
items
=
items
}
update_quality
()
{
for
(
const
item
of
this
.
items
)
{
if
(
item
.
name
!=
'Aged Brie'
&&
item
.
name
!=
'Backstage passes to a TAFKAL80ETC concert'
)
{
if
(
item
.
quality
>
0
)
{
if
(
item
.
name
!=
'Sulfuras, Hand of Ragnaros'
)
{
item
.
quality
=
item
.
quality
-
1
}
}
}
else
{
if
(
item
.
quality
<
50
)
{
item
.
quality
=
item
.
quality
+
1
if
(
item
.
name
==
'Backstage passes to a TAFKAL80ETC concert'
)
{
if
(
item
.
sell_in
<
11
)
{
if
(
item
.
quality
<
50
)
{
item
.
quality
=
item
.
quality
+
1
}
}
if
(
item
.
sell_in
<
6
)
{
if
(
item
.
quality
<
50
)
{
item
.
quality
=
item
.
quality
+
1
}
}
}
}
}
if
(
item
.
name
!=
'Sulfuras, Hand of Ragnaros'
)
{
item
.
sell_in
=
item
.
sell_in
-
1
}
if
(
item
.
sell_in
<
0
)
{
if
(
item
.
name
!=
'Aged Brie'
)
{
if
(
item
.
name
!=
'Backstage passes to a TAFKAL80ETC concert'
)
{
if
(
item
.
quality
>
0
)
{
if
(
item
.
name
!=
'Sulfuras, Hand of Ragnaros'
)
{
item
.
quality
=
item
.
quality
-
1
}
}
}
else
{
item
.
quality
=
item
.
quality
-
item
.
quality
}
}
else
{
if
(
item
.
quality
<
50
)
{
item
.
quality
=
item
.
quality
+
1
}
}
}
item
.
_updateItem
(
item
);
}
}
// update_quality() {
// for (const item of this.items) {
// if (
// item.name != 'Aged Brie' &&
// item.name != 'Backstage passes to a TAFKAL80ETC concert'
// ) {
// if (item.quality > 0) {
// if (item.name != 'Sulfuras, Hand of Ragnaros') {
// item.quality = item.quality - 1
// }
// }
// } else {
// if (item.quality < 50) {
// item.quality = item.quality + 1
// if (
// item.name == 'Backstage passes to a TAFKAL80ETC concert'
// ) {
// if (item.sell_in < 11) {
// if (item.quality < 50) {
// item.quality = item.quality + 1
// }
// }
// if (item.sell_in < 6) {
// if (item.quality < 50) {
// item.quality = item.quality + 1
// }
// }
// }
// }
// }
// if (item.name != 'Sulfuras, Hand of Ragnaros') {
// item.sell_in = item.sell_in - 1
// }
// if (item.sell_in < 0) {
// if (item.name != 'Aged Brie') {
// if (
// item.name != 'Backstage passes to a TAFKAL80ETC concert'
// ) {
// if (item.quality > 0) {
// if (item.name != 'Sulfuras, Hand of Ragnaros') {
// item.quality = item.quality - 1
// }
// }
// } else {
// item.quality =
// item.quality - item.quality
// }
// } else {
// if (item.quality < 50) {
// item.quality = item.quality + 1
// }
// }
// }
// }
// }
}
gildedRose/src/item.js
View file @
85e441bf
const
backStage
=
'Backstage passes to a TAFKAL80ETC concert'
const
Sulfuras
=
'Sulfuras, Hand of Ragnaros'
const
AgedBrie
=
'Aged Brie'
export
class
Item
{
name
sell_in
...
...
@@ -12,4 +15,51 @@ export class Item {
toString
()
{
return
`
${
this
.
name
}
,
${
this
.
sell_in
}
,
${
this
.
quality
}
`
}
_updateItem
(
item
)
{
if
(
item
.
name
!=
AgedBrie
&&
item
.
name
!=
backStage
)
{
if
(
item
.
quality
>
0
)
{
if
(
item
.
name
!=
Sulfuras
)
{
item
.
quality
=
item
.
quality
-
1
}
}
}
else
{
if
(
item
.
quality
<
50
)
{
item
.
quality
=
item
.
quality
+
1
if
(
item
.
name
==
backStage
)
{
if
(
item
.
sell_in
<
11
)
{
if
(
item
.
quality
<
50
)
{
item
.
quality
=
item
.
quality
+
1
}
}
if
(
item
.
sell_in
<
6
)
{
if
(
item
.
quality
<
50
)
{
item
.
quality
=
item
.
quality
+
1
}
}
}
}
}
if
(
item
.
name
!=
Sulfuras
)
{
item
.
sell_in
=
item
.
sell_in
-
1
}
if
(
item
.
sell_in
<
0
)
{
if
(
item
.
name
!=
AgedBrie
)
{
if
(
item
.
name
!=
backStage
)
{
if
(
item
.
quality
>
0
)
{
if
(
item
.
name
!=
Sulfuras
)
{
item
.
quality
=
item
.
quality
-
1
}
}
else
{
item
.
quality
=
item
.
quality
-
item
.
quality
}
}
else
{
if
(
item
.
quality
<
50
)
{
item
.
quality
=
item
.
quality
+
1
}
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment