mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 12:22:12 +00:00
Merge pull request #2 from codecop/topull
add Eclipse and IDEA project settings and do some code formatting
This commit is contained in:
commit
370c77bb6b
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.idea/workspace.xml
|
||||||
1
.idea/.name
Normal file
1
.idea/.name
Normal file
@ -0,0 +1 @@
|
|||||||
|
GuildedRose
|
||||||
23
.idea/compiler.xml
Normal file
23
.idea/compiler.xml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||||
|
<resourceExtensions />
|
||||||
|
<wildcardResourcePatterns>
|
||||||
|
<entry name="!?*.java" />
|
||||||
|
<entry name="!?*.form" />
|
||||||
|
<entry name="!?*.class" />
|
||||||
|
<entry name="!?*.groovy" />
|
||||||
|
<entry name="!?*.scala" />
|
||||||
|
<entry name="!?*.flex" />
|
||||||
|
<entry name="!?*.kt" />
|
||||||
|
<entry name="!?*.clj" />
|
||||||
|
</wildcardResourcePatterns>
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile default="true" name="Default" enabled="false">
|
||||||
|
<processorPath useClasspath="true" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
||||||
5
.idea/copyright/profiles_settings.xml
Normal file
5
.idea/copyright/profiles_settings.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<component name="CopyrightManager">
|
||||||
|
<settings default="">
|
||||||
|
<module2copyright />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
5
.idea/encodings.xml
Normal file
5
.idea/encodings.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
|
||||||
|
</project>
|
||||||
|
|
||||||
10
.idea/misc.xml
Normal file
10
.idea/misc.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<entry_points version="2.0" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_5" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
||||||
9
.idea/modules.xml
Normal file
9
.idea/modules.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/Java/Java.iml" filepath="$PROJECT_DIR$/Java/Java.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
||||||
5
.idea/scopes/scope_settings.xml
Normal file
5
.idea/scopes/scope_settings.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<component name="DependencyValidationManager">
|
||||||
|
<state>
|
||||||
|
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
8
.idea/vcs.xml
Normal file
8
.idea/vcs.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="" />
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
|
|
||||||
7
Java/.classpath
Normal file
7
Java/.classpath
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path=""/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||||
|
<classpathentry kind="output" path=""/>
|
||||||
|
</classpath>
|
||||||
1
Java/.gitignore
vendored
Normal file
1
Java/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.class
|
||||||
17
Java/.project
Normal file
17
Java/.project
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>GildedRose.java</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
22
Java/Java.iml
Normal file
22
Java/Java.iml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||||
|
<output url="file://$MODULE_DIR$" />
|
||||||
|
<output-test url="file://$MODULE_DIR$" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$" isTestSource="true" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.10.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
|
|
||||||
1
Java/com/gildedrose/GildedRose.java
Executable file → Normal file
1
Java/com/gildedrose/GildedRose.java
Executable file → Normal file
@ -1,4 +1,5 @@
|
|||||||
package com.gildedrose;
|
package com.gildedrose;
|
||||||
|
|
||||||
class GildedRose {
|
class GildedRose {
|
||||||
Item[] items;
|
Item[] items;
|
||||||
|
|
||||||
|
|||||||
@ -1,15 +1,17 @@
|
|||||||
package com.gildedrose;
|
package com.gildedrose;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class GildedRoseTest {
|
public class GildedRoseTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void foo() {
|
public void foo() {
|
||||||
Item[] items = new Item[] { new Item("foo", 0, 0) };
|
Item[] items = new Item[] { new Item("foo", 0, 0) };
|
||||||
GildedRose app = new GildedRose(items);
|
GildedRose app = new GildedRose(items);
|
||||||
app.updateQuality();
|
app.updateQuality();
|
||||||
assertEquals("fixme", app.items[0].name);
|
assertEquals("fixme", app.items[0].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
1
Java/com/gildedrose/Item.java
Executable file → Normal file
1
Java/com/gildedrose/Item.java
Executable file → Normal file
@ -1,4 +1,5 @@
|
|||||||
package com.gildedrose;
|
package com.gildedrose;
|
||||||
|
|
||||||
public class Item {
|
public class Item {
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
|
|||||||
29
Java/com/gildedrose/TexttestFixture.java
Executable file → Normal file
29
Java/com/gildedrose/TexttestFixture.java
Executable file → Normal file
@ -2,20 +2,21 @@ package com.gildedrose;
|
|||||||
|
|
||||||
public class TexttestFixture {
|
public class TexttestFixture {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("OMGHAI!");
|
System.out.println("OMGHAI!");
|
||||||
|
|
||||||
Item[] items = new Item[] { new Item("+5 Dexterity Vest", 10, 20),
|
Item[] items = new Item[] {
|
||||||
new Item("Aged Brie", 2, 0),
|
new Item("+5 Dexterity Vest", 10, 20), //
|
||||||
new Item("Elixir of the Mongoose", 5, 7),
|
new Item("Aged Brie", 2, 0), //
|
||||||
new Item("Sulfuras, Hand of Ragnaros", 0, 80),
|
new Item("Elixir of the Mongoose", 5, 7), //
|
||||||
new Item("Sulfuras, Hand of Ragnaros", -1, 80),
|
new Item("Sulfuras, Hand of Ragnaros", 0, 80), //
|
||||||
new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
|
new Item("Sulfuras, Hand of Ragnaros", -1, 80),
|
||||||
new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
|
new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
|
||||||
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
|
new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
|
||||||
// this conjured item does not work properly yet
|
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
|
||||||
new Item("Conjured Mana Cake", 3, 6) };
|
// this conjured item does not work properly yet
|
||||||
|
new Item("Conjured Mana Cake", 3, 6) };
|
||||||
|
|
||||||
GildedRose app = new GildedRose(items);
|
GildedRose app = new GildedRose(items);
|
||||||
|
|
||||||
int days = 2;
|
int days = 2;
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
@ -29,8 +30,8 @@ public class TexttestFixture {
|
|||||||
System.out.println(item);
|
System.out.println(item);
|
||||||
}
|
}
|
||||||
System.out.println();
|
System.out.println();
|
||||||
app.updateQuality();
|
app.updateQuality();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
3
js/.gitignore
vendored
3
js/.gitignore
vendored
@ -1,3 +0,0 @@
|
|||||||
*.swp
|
|
||||||
*~
|
|
||||||
*.bak
|
|
||||||
61
js/README.md
61
js/README.md
@ -1,61 +0,0 @@
|
|||||||
If you want to get cracking on the JavaScript source then do this:
|
|
||||||
|
|
||||||
git clone git@github.com:guyroyse/gilded-rose-javascript.git
|
|
||||||
|
|
||||||
Hi and welcome to team Gilded Rose.
|
|
||||||
|
|
||||||
As you know, we are a small inn with a prime location in a prominent city ran
|
|
||||||
by a friendly innkeeper named Allison. We also buy and sell only the finest
|
|
||||||
goods. Unfortunately, our goods are constantly degrading in quality as they
|
|
||||||
approach their sell by date.
|
|
||||||
|
|
||||||
We have a system in place that updates our inventory for us. It was developed
|
|
||||||
by a no-nonsense type named Leeroy, who has moved on to new adventures. Your
|
|
||||||
task is to add the new feature to our system so that we can begin selling a
|
|
||||||
new category of items.
|
|
||||||
|
|
||||||
First an introduction to our system:
|
|
||||||
|
|
||||||
- All items have a *sell_in* value which denotes the number of days we have to
|
|
||||||
sell the item
|
|
||||||
|
|
||||||
- All items have a *quality* value which denotes how valuable the item is
|
|
||||||
|
|
||||||
- At the end of each day our system lowers both values for every item
|
|
||||||
|
|
||||||
Pretty simple, right? Well this is where it gets interesting:
|
|
||||||
|
|
||||||
- Once the *sell_in* days is less then zero, *quality* degrades twice as fast
|
|
||||||
|
|
||||||
- The *quality* of an item is never negative
|
|
||||||
|
|
||||||
- "Aged Brie" actually increases in *quality* the older it gets
|
|
||||||
|
|
||||||
- The *quality* of an item is never more than 50
|
|
||||||
|
|
||||||
- "Sulfuras", being a legendary item, never has to be sold nor does it
|
|
||||||
decrease in *quality*
|
|
||||||
|
|
||||||
- "Backstage passes", like aged brie, increases in *quality* as it's *sell_in*
|
|
||||||
value decreases; *quality* increases by 2 when there are 10 days or less
|
|
||||||
and by 3 when there are 5 days or less but *quality* drops to 0 after the
|
|
||||||
concert
|
|
||||||
|
|
||||||
We have recently signed a supplier of conjured items. This requires an update
|
|
||||||
to our system:
|
|
||||||
|
|
||||||
- "Conjured" items degrade in *quality* twice as fast as normal items
|
|
||||||
|
|
||||||
Feel free to make any changes to the *update_quality* method and add any new
|
|
||||||
code as long as everything still works correctly. However, do not alter the
|
|
||||||
*Item* class or *items* property as those belong to the goblin in the corner
|
|
||||||
who will insta-rage and one-shot you as he doesn't believe in shared code
|
|
||||||
ownership.
|
|
||||||
|
|
||||||
Just for clarification, an item can never have its *quality* increase above 50,
|
|
||||||
however "Sulfuras" is a legendary item and as such its *quality* is 80 and it
|
|
||||||
never alters.
|
|
||||||
|
|
||||||
Sources:
|
|
||||||
<http://www.iamnotmyself.com/2011/02/13/RefactorThisTheGildedRoseKata.aspx>
|
|
||||||
<https://github.com/professor/GildedRose>
|
|
||||||
@ -1,7 +1,9 @@
|
|||||||
describe("Gilded Rose", function() {
|
describe("Gilded Rose", function() {
|
||||||
|
|
||||||
it("should do something", function() {
|
it("should foo", function() {
|
||||||
update_quality
|
items = [ new Item("foo", 0, 0) ];
|
||||||
|
update_quality();
|
||||||
|
expect(items[0].name).toEqual("fixme");
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import unittest
|
|||||||
|
|
||||||
from gilded_rose import Item, GildedRose
|
from gilded_rose import Item, GildedRose
|
||||||
|
|
||||||
|
|
||||||
class GildedRoseTest(unittest.TestCase):
|
class GildedRoseTest(unittest.TestCase):
|
||||||
def test_foo(self):
|
def test_foo(self):
|
||||||
items = [Item("foo", 0, 0)]
|
items = [Item("foo", 0, 0)]
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from gilded_rose import *
|
from gilded_rose import *
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
5
ruby/.buildpath
Normal file
5
ruby/.buildpath
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<buildpath>
|
||||||
|
<buildpathentry kind="src" path=""/>
|
||||||
|
<buildpathentry kind="con" path="org.eclipse.dltk.launching.INTERPRETER_CONTAINER"/>
|
||||||
|
</buildpath>
|
||||||
5
ruby/.loadpath
Normal file
5
ruby/.loadpath
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<loadpath>
|
||||||
|
<pathentry path="" type="src" />
|
||||||
|
<pathentry path="org.rubypeople.rdt.launching.RUBY_CONTAINER" type="con" />
|
||||||
|
</loadpath>
|
||||||
23
ruby/.project
Normal file
23
ruby/.project
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>GildedRose.rb</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.rubypeople.rdt.core.rubybuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.dltk.core.scriptbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.rubypeople.rdt.core.rubynature</nature>
|
||||||
|
<nature>org.eclipse.dltk.ruby.core.nature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
2
ruby/gilded_rose.rb
Executable file → Normal file
2
ruby/gilded_rose.rb
Executable file → Normal file
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
class GildedRose
|
class GildedRose
|
||||||
|
|
||||||
def initialize(items)
|
def initialize(items)
|
||||||
@items = items
|
@items = items
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,30 +4,30 @@ require File.join(File.dirname(__FILE__), 'gilded_rose')
|
|||||||
|
|
||||||
puts "OMGHAI!"
|
puts "OMGHAI!"
|
||||||
items = [
|
items = [
|
||||||
Item.new(name="+5 Dexterity Vest", sell_in=10, quality=20),
|
Item.new(name="+5 Dexterity Vest", sell_in=10, quality=20),
|
||||||
Item.new(name="Aged Brie", sell_in=2, quality=0),
|
Item.new(name="Aged Brie", sell_in=2, quality=0),
|
||||||
Item.new(name="Elixir of the Mongoose", sell_in=5, quality=7),
|
Item.new(name="Elixir of the Mongoose", sell_in=5, quality=7),
|
||||||
Item.new(name="Sulfuras, Hand of Ragnaros", sell_in=0, quality=80),
|
Item.new(name="Sulfuras, Hand of Ragnaros", sell_in=0, quality=80),
|
||||||
Item.new(name="Sulfuras, Hand of Ragnaros", sell_in=-1, quality=80),
|
Item.new(name="Sulfuras, Hand of Ragnaros", sell_in=-1, quality=80),
|
||||||
Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=15, quality=20),
|
Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=15, quality=20),
|
||||||
Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=10, quality=49),
|
Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=10, quality=49),
|
||||||
Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=5, quality=49),
|
Item.new(name="Backstage passes to a TAFKAL80ETC concert", sell_in=5, quality=49),
|
||||||
# This Conjured item does not work properly yet
|
# This Conjured item does not work properly yet
|
||||||
Item.new(name="Conjured Mana Cake", sell_in=3, quality=6), # <-- :O
|
Item.new(name="Conjured Mana Cake", sell_in=3, quality=6), # <-- :O
|
||||||
]
|
]
|
||||||
|
|
||||||
days = 2
|
days = 2
|
||||||
if ARGV.size > 0
|
if ARGV.size > 0
|
||||||
days = ARGV[0].to_i + 1
|
days = ARGV[0].to_i + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
gilded_rose = GildedRose.new items
|
gilded_rose = GildedRose.new items
|
||||||
(0...days).each do |day|
|
(0...days).each do |day|
|
||||||
puts "-------- day #{day} --------"
|
puts "-------- day #{day} --------"
|
||||||
puts "name, sellIn, quality"
|
puts "name, sellIn, quality"
|
||||||
items.each do |item|
|
items.each do |item|
|
||||||
puts item
|
puts item
|
||||||
end
|
end
|
||||||
puts ""
|
puts ""
|
||||||
gilded_rose.update_quality
|
gilded_rose.update_quality
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user