forked from professor/GildedRose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Todd Sedano
committed
Mar 22, 2011
1 parent
1fd1d99
commit 205d4d7
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
class GildedRose | ||
|
||
@items = {} | ||
|
||
def initialize | ||
items << Item("+5 Dexterity Vest", 10, 20) | ||
items << Item("Aged Brie", 2, 0) | ||
items << Item("Elixir of the Mongoose", 5, 7) | ||
items << Item("Sulfuras, Hand of Ragnaros", 0, 80) | ||
items << Item("Backstage passes to a TAFKAL80ETC concert", 15, 20) | ||
items << Item("Conjured Mana Cake", 3, 6) | ||
end | ||
|
||
self.def updateQuality do | ||
|
||
@items.each do |item| | ||
if ((!"Aged Brie".equals(item.getName())) && !"Backstage passes to a TAFKAL80ETC concert".equals(item.getName())) | ||
if (item.getQuality() > 0) | ||
if (!"Sulfuras, Hand of Ragnaros".equals(item.getName())) | ||
item.setQuality(item.getQuality() - 1); | ||
end | ||
end | ||
else | ||
if (item.getQuality() < 50) | ||
item.setQuality(item.getQuality() + 1); | ||
|
||
if ("Backstage passes to a TAFKAL80ETC concert".equals(item.getName())) | ||
if (item.getSellIn() < 11) | ||
if (item.getQuality() < 50) | ||
item.setQuality(item.getQuality() + 1); | ||
end | ||
end | ||
|
||
if (item.getSellIn() < 6) | ||
if (item.getQuality() < 50) | ||
item.setQuality(item.getQuality() + 1); | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
if (!"Sulfuras, Hand of Ragnaros".equals(item.getName())) | ||
item.setSellIn(item.getSellIn() - 1); | ||
end | ||
|
||
if (item.getSellIn() < 0) | ||
if (!"Aged Brie".equals(item.getName())) | ||
if (!"Backstage passes to a TAFKAL80ETC concert".equals(item.getName())) | ||
if (item.getQuality() > 0) | ||
if (!"Sulfuras, Hand of Ragnaros".equals(item.getName())) | ||
item.setQuality(item.getQuality() - 1); | ||
end | ||
end | ||
else | ||
item.setQuality(item.getQuality() - item.getQuality()); | ||
end | ||
else | ||
if (item.getQuality() < 50) | ||
item.setQuality(item.getQuality() + 1); | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'spec_helper' | ||
|
||
describe GildedRose do | ||
|
||
it "should do something" do | ||
|
||
end | ||
|
||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Item | ||
|
||
attr_accessor :name, :sellin, :quality | ||
|
||
|
||
def initialize (name, sellIn, quality) | ||
@name = name | ||
@sellIn = sellIn | ||
@quality = quality | ||
end | ||
|
||
|
||
end |