mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 04:12:13 +00:00
format Java code (only whitespace changes)
This commit is contained in:
parent
75a2a15f14
commit
7c817b1032
123
Java/com/gildedrose/GildedRose.java
Executable file → Normal file
123
Java/com/gildedrose/GildedRose.java
Executable file → Normal file
@ -1,61 +1,62 @@
|
|||||||
package com.gildedrose;
|
package com.gildedrose;
|
||||||
class GildedRose {
|
|
||||||
Item[] items;
|
class GildedRose {
|
||||||
|
Item[] items;
|
||||||
public GildedRose(Item[] items) {
|
|
||||||
this.items = items;
|
public GildedRose(Item[] items) {
|
||||||
}
|
this.items = items;
|
||||||
|
}
|
||||||
public void updateQuality() {
|
|
||||||
for (int i = 0; i < items.length; i++) {
|
public void updateQuality() {
|
||||||
if (!items[i].name.equals("Aged Brie")
|
for (int i = 0; i < items.length; i++) {
|
||||||
&& !items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
if (!items[i].name.equals("Aged Brie")
|
||||||
if (items[i].quality > 0) {
|
&& !items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||||
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
if (items[i].quality > 0) {
|
||||||
items[i].quality = items[i].quality - 1;
|
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||||
}
|
items[i].quality = items[i].quality - 1;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
if (items[i].quality < 50) {
|
} else {
|
||||||
items[i].quality = items[i].quality + 1;
|
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].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||||
if (items[i].quality < 50) {
|
if (items[i].sellIn < 11) {
|
||||||
items[i].quality = items[i].quality + 1;
|
if (items[i].quality < 50) {
|
||||||
}
|
items[i].quality = items[i].quality + 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (items[i].sellIn < 6) {
|
|
||||||
if (items[i].quality < 50) {
|
if (items[i].sellIn < 6) {
|
||||||
items[i].quality = items[i].quality + 1;
|
if (items[i].quality < 50) {
|
||||||
}
|
items[i].quality = items[i].quality + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
|
||||||
items[i].sellIn = items[i].sellIn - 1;
|
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
||||||
}
|
items[i].sellIn = items[i].sellIn - 1;
|
||||||
|
}
|
||||||
if (items[i].sellIn < 0) {
|
|
||||||
if (!items[i].name.equals("Aged Brie")) {
|
if (items[i].sellIn < 0) {
|
||||||
if (!items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
if (!items[i].name.equals("Aged Brie")) {
|
||||||
if (items[i].quality > 0) {
|
if (!items[i].name.equals("Backstage passes to a TAFKAL80ETC concert")) {
|
||||||
if (!items[i].name.equals("Sulfuras, Hand of Ragnaros")) {
|
if (items[i].quality > 0) {
|
||||||
items[i].quality = items[i].quality - 1;
|
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 {
|
||||||
}
|
items[i].quality = items[i].quality - items[i].quality;
|
||||||
} else {
|
}
|
||||||
if (items[i].quality < 50) {
|
} else {
|
||||||
items[i].quality = items[i].quality + 1;
|
if (items[i].quality < 50) {
|
||||||
}
|
items[i].quality = items[i].quality + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -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
|
|
||||||
public void foo() {
|
@Test
|
||||||
Item[] items = new Item[] { new Item("foo", 0, 0) };
|
public void foo() {
|
||||||
GildedRose app = new GildedRose(items);
|
Item[] items = new Item[] { new Item("foo", 0, 0) };
|
||||||
app.updateQuality();
|
GildedRose app = new GildedRose(items);
|
||||||
assertEquals("fixme", app.items[0].name);
|
app.updateQuality();
|
||||||
}
|
assertEquals("fixme", app.items[0].name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
39
Java/com/gildedrose/Item.java
Executable file → Normal file
39
Java/com/gildedrose/Item.java
Executable file → Normal file
@ -1,19 +1,20 @@
|
|||||||
package com.gildedrose;
|
package com.gildedrose;
|
||||||
public class Item {
|
|
||||||
|
public class Item {
|
||||||
public String name;
|
|
||||||
|
public String name;
|
||||||
public int sellIn;
|
|
||||||
|
public int sellIn;
|
||||||
public int quality;
|
|
||||||
|
public int quality;
|
||||||
public Item(String name, int sellIn, int quality) {
|
|
||||||
this.name = name;
|
public Item(String name, int sellIn, int quality) {
|
||||||
this.sellIn = sellIn;
|
this.name = name;
|
||||||
this.quality = quality;
|
this.sellIn = sellIn;
|
||||||
}
|
this.quality = quality;
|
||||||
|
}
|
||||||
public String toString() {
|
|
||||||
return this.name + ", " + this.sellIn + ", " + this.quality;
|
public String toString() {
|
||||||
}
|
return this.name + ", " + this.sellIn + ", " + this.quality;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
73
Java/com/gildedrose/TexttestFixture.java
Executable file → Normal file
73
Java/com/gildedrose/TexttestFixture.java
Executable file → Normal file
@ -1,36 +1,37 @@
|
|||||||
package com.gildedrose;
|
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;
|
|
||||||
if (args.length > 0) {
|
int days = 2;
|
||||||
days = Integer.parseInt(args[0]) + 1;
|
if (args.length > 0) {
|
||||||
}
|
days = Integer.parseInt(args[0]) + 1;
|
||||||
|
}
|
||||||
for (int i = 0; i < days; i++) {
|
|
||||||
System.out.println("-------- day " + i + " --------");
|
for (int i = 0; i < days; i++) {
|
||||||
System.out.println("name, sellIn, quality");
|
System.out.println("-------- day " + i + " --------");
|
||||||
for (Item item : items) {
|
System.out.println("name, sellIn, quality");
|
||||||
System.out.println(item);
|
for (Item item : items) {
|
||||||
}
|
System.out.println(item);
|
||||||
System.out.println();
|
}
|
||||||
app.updateQuality();
|
System.out.println();
|
||||||
}
|
app.updateQuality();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user