From 57f7d01294e8d04b57230f3e65ce7c83fb0a6fe8 Mon Sep 17 00:00:00 2001 From: Janne Laulajainen Date: Wed, 19 Oct 2016 18:11:24 +0300 Subject: [PATCH 1/6] edit 1 --- bin/.gitignore | 1 + bin/fi/oulu/tol/sqat/GildedRose.class | Bin 2380 -> 1813 bytes bin/fi/oulu/tol/sqat/Item.class | Bin 1034 -> 1660 bytes .../oulu/tol/sqat/tests/GildedRoseTest.class | Bin 504 -> 6286 bytes src/fi/oulu/tol/sqat/GildedRose.java | 57 ++-- src/fi/oulu/tol/sqat/Item.java | 27 ++ .../oulu/tol/sqat/tests/GildedRoseTest.java | 277 +++++++++++++++--- 7 files changed, 299 insertions(+), 63 deletions(-) create mode 100644 bin/.gitignore diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..76b3e7b --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +/fi/ diff --git a/bin/fi/oulu/tol/sqat/GildedRose.class b/bin/fi/oulu/tol/sqat/GildedRose.class index f244eba73874c91f18244a292b7f88cc3b4b5f80..3487df6b1ec20ba69e916e22c5a9e5e39dd86f41 100644 GIT binary patch literal 1813 zcmaJ>OK%%h7(L@S@gvjNaoQA8TAWgfAHiaA~jx8Hmt8Uh_u4QJOTf)sw8m6XevzDU=;8ze`5pRjCDQea1%+iWpaTT;1 zuDts6(skmhl>Yd6$q3Ypy1u%k+jC;cBz~-DRfJg{GQLE;{oX7J4oZB;Q4V{V$vN|35t-3IsATDySMn&aK#}!pQz9t+;cjB%U z7xB6L#MON9;+gTev3SL*Rdk!FrtqSQ9EKHyN#O=D40qidvVv5OsCWr4bGkIWV(Y@u zTNZw1UzR4LD#oNq*lGDo@wkc!2^%78NjJ?xO-iR!6g)hmwg*q@uBs>^%))QSYPbb4 z&ABPn&E>i+oPqe1sA+L)IX)}6Nw(!k*Xt^7NY_qs*tV1nE2)^1B>awXo3&L8{tMih zlFJHR6Kl<-2$!t7UC}2Dxi*oV(ap%|KtH#vjh_U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862181a0a6b22a57fca5a1788d6a3f6..a03ef1de6d45b0ade350282175a4c5f1c518077e 100644 GIT binary patch literal 1660 zcma)6ZBNrs7(I6z8|%u3z(5%<3Ocre6hVjv!WW`(38Dr=BA+Z&4k8%Q0*0g(df?!5Q_lTCa^WtM1jql5C95?6J|>H=Sl^&ehDSV;U_p zu%tm+Fdaz5^8+Z*D>*jqpS0yCK9D%mgi=O~OJA48>I zVz;>oJp7N$d}QV$j0H8f*oWku(LS7`Sg2i~cqNqLyT&O~p{t2Z*hD65qI4VJ#|XeF z0#5$}uuR?Bsyz3V4j5_)GSqq*&Jb|6tI-ZaK}kC>o9so(r)q<5$w}+KhLiP2tjH0Y z<3ND(n&pLP!Yn|~*AuG;s#(3RX5Ci6cNBugSv@uW6?0ll{so%6QT zrA;yvI~h!(z!NM-5Yc)EZ#j|(e_}U?6s~E}zV%g>Tf2pb{1Bu9E0IKsy+ocx65$Us XipY)eTPKl?TZqW-P!f6S-@)o%P=V0+ delta 323 zcmeyv)5XDc>ff$?3=9m$3_2URJQydxW>jWWn#|86uE@#2$e_l!O2XlI%0|&;lf-%X$A%npoyZB&$5aefJ_GIS7uNFk~}~;Wb;(lz%@e5 z6QA4-G*1=XJSm`g(m?a%HPo@1qk(RY>|_x(9Wf1ba}u? diff --git a/bin/fi/oulu/tol/sqat/tests/GildedRoseTest.class b/bin/fi/oulu/tol/sqat/tests/GildedRoseTest.class index e44e81ce2b232358b6069c215dc740c0984c2b8c..83caf4a6ed84811e68833b6feaf8646775ae79b2 100644 GIT binary patch literal 6286 zcmbuCTWlQF8OOilOLn|o;;k_umnKXp0o!r1yEYrU*bO+r2^-cVwH?zmf@SO-uO}YQ zBr~&4+?G-(w@^x;5*4ED169?+1641O5I{g5K!~;vAO!S*s_NyXstSFm5KtBVXD+)F z@A2-STH3Yea?bZV|MUO8^ZB*^J^KO?4bX!zYGSl?PD`0(y_|APJ!KzPoRp*5j-A@4 z=|#0TVcO~xu4B}~D0x&_Qc}8Nlu`#~j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<0DcI-j{x{Ftoh#%VAz_0hE;1mfU~2CPJaq= CRTE$U delta 275 zcmZXNOAY}+7=){5hM|r3`v!<)A}mEB5+@J~8xcAl3zC_(b_0nxi50PM04K5%HApOM zs`~G$|NHlihbiyR>kU8?<%8^%!|mmIsXGE@r8*R_dYhS&FcCf6#&Jh0Uk?^);BEEd z*cWa~B7>ZbtUzkx&E3_O%Wl{Am8Tu#Q4o-m_rw)NTxC=p9;dRt0}Kd+5T@EZ@6rW5 zR68Sb;=_QX263P!})MWAoSr?>#Ajv9-w1^_C^hYZ)Hc)y2 D;W;H; diff --git a/src/fi/oulu/tol/sqat/GildedRose.java b/src/fi/oulu/tol/sqat/GildedRose.java index 24741c6..6ab5c7a 100644 --- a/src/fi/oulu/tol/sqat/GildedRose.java +++ b/src/fi/oulu/tol/sqat/GildedRose.java @@ -23,76 +23,73 @@ public static void updateEndOfDay() { for (int i = 0; i < items.size(); i++) { - if ((!"Aged Brie".equals(items.get(i).getName())) && !"Backstage passes to a TAFKAL80ETC concert".equals(items.get(i).getName())) + Item item = items.get(i); + if ((!"Aged Brie".equals(item.getName())) && !"Backstage passes to a TAFKAL80ETC concert".equals(item.getName())) { - if (items.get(i).getQuality() > 0) + if (item.getQuality() > 0) { - if (!"Sulfuras, Hand of Ragnaros".equals(items.get(i).getName())) - { - items.get(i).setQuality(items.get(i).getQuality() - 1); - } + item.decreaseQuality(1); } } else { - if (items.get(i).getQuality() < 50) + if (item.getQuality() < 50) { - items.get(i).setQuality(items.get(i).getQuality() + 1); + item.setQuality(item.getQuality() + 1); - if ("Backstage passes to a TAFKAL80ETC concert".equals(items.get(i).getName())) + if ("Backstage passes to a TAFKAL80ETC concert".equals(item.getName())) { - if (items.get(i).getSellIn() < 11) + if (item.getSellIn() < 11) { - if (items.get(i).getQuality() < 50) + if (item.getQuality() < 50) { - items.get(i).setQuality(items.get(i).getQuality() + 1); + item.increaseQuality(1); } } - if (items.get(i).getSellIn() < 6) + if (item.getSellIn() < 6) { - if (items.get(i).getQuality() < 50) + if (item.getQuality() < 50) { - items.get(i).setQuality(items.get(i).getQuality() + 1); + item.increaseQuality(1); } } } } } - if (!"Sulfuras, Hand of Ragnaros".equals(items.get(i).getName())) - { - items.get(i).setSellIn(items.get(i).getSellIn() - 1); - } + item.decreaseSellIn(); - if (items.get(i).getSellIn() < 0) + if (item.getSellIn() < 0) { - if (!"Aged Brie".equals(items.get(i).getName())) + if (!"Aged Brie".equals(item.getName())) { - if (!"Backstage passes to a TAFKAL80ETC concert".equals(items.get(i).getName())) + if (!"Backstage passes to a TAFKAL80ETC concert".equals(item.getName())) { - if (items.get(i).getQuality() > 0) + if (item.getQuality() > 0) { - if (!"Sulfuras, Hand of Ragnaros".equals(items.get(i).getName())) - { - items.get(i).setQuality(items.get(i).getQuality() - 1); - } + item.decreaseQuality(1); } } else { - items.get(i).setQuality(items.get(i).getQuality() - items.get(i).getQuality()); + item.setQuality(item.getQuality() - item.getQuality()); } } else { - if (items.get(i).getQuality() < 50) + if (item.getQuality() < 50) { - items.get(i).setQuality(items.get(i).getQuality() + 1); + item.increaseQuality(1); } } } + if ("Sulfuras, Hand of Ragnaros".equals(item.getName())) + { + item.setSulfuras();/*if sulfuras, ignore everything above, set sulfuras stats*/ + } } } + } diff --git a/src/fi/oulu/tol/sqat/Item.java b/src/fi/oulu/tol/sqat/Item.java index 447b7fe..a8a7562 100644 --- a/src/fi/oulu/tol/sqat/Item.java +++ b/src/fi/oulu/tol/sqat/Item.java @@ -11,6 +11,33 @@ public Item(String name, int sellIn, int quality) { this.setSellIn(sellIn); this.setQuality(quality); } + public boolean HasExpired (int x){ + return true; + } + public boolean isMaximumQuality(){ + return true; + } + public boolean hasZeroQuality(){ + return true; + } + + + public void decreaseQuality(int x){ + quality = quality - x; + } + + public void increaseQuality(int x){ + quality = quality + x; + } + + public void decreaseSellIn(){ + sellIn = sellIn - 1; + } + + public void setSulfuras(){ + quality = 80; + sellIn = 5; + } /* Generated getter and setter code */ public String getName() { diff --git a/src/fi/oulu/tol/sqat/tests/GildedRoseTest.java b/src/fi/oulu/tol/sqat/tests/GildedRoseTest.java index 7aceb2e..75c4a9b 100644 --- a/src/fi/oulu/tol/sqat/tests/GildedRoseTest.java +++ b/src/fi/oulu/tol/sqat/tests/GildedRoseTest.java @@ -1,42 +1,253 @@ package fi.oulu.tol.sqat.tests; - import static org.junit.Assert.*; - import java.util.ArrayList; import java.util.List; - import org.junit.Test; - import fi.oulu.tol.sqat.GildedRose; import fi.oulu.tol.sqat.Item; - public class GildedRoseTest { - -// Example scenarios for testing -// Item("+5 Dexterity Vest", 10, 20)); -// Item("Aged Brie", 2, 0)); -// Item("Elixir of the Mongoose", 5, 7)); -// Item("Sulfuras, Hand of Ragnaros", 0, 80)); -// Item("Backstage passes to a TAFKAL80ETC concert", 15, 20)); -// Item("Conjured Mana Cake", 3, 6)); - - @Test - public void testUpdateEndOfDay_AgedBrie_Quality_10_11() { - // Arrange - GildedRose store = new GildedRose(); - store.addItem(new Item("Aged Brie", 2, 10) ); - - // Act - store.updateEndOfDay(); - - // Assert - List items = store.getItems(); - Item itemBrie = items.get(0); - assertEquals(11, itemBrie.getQuality()); - } - - @Test - public void testUpdateEndOfDay() { - fail("Test not implemented"); - } +GildedRose store = new GildedRose(); +// Test Aged Brie +@Test +public void testUpdateEndOfDay_AgedBrie_Quality_2_10() { +// Arrange +store.addItem(new Item("Aged Brie", 2, 10) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "Quality of Aged Brie increases"; +assertEquals(failMessage, 11,quality); } +@Test +public void testUpdateEndOfDay_AgedBrie_Quality_10_50() { +// Arrange +store.addItem(new Item("Aged Brie", 10, 50) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "The Quality of an item is never more than 50"; +assertEquals(failMessage, 50, quality); +} +@Test +public void testUpdateEndOfDay_AgedBrie_Quality_0_10() { +// Arrange +store.addItem(new Item("Aged Brie", 0, 10) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "The Quality of Aged Brie increases twice after SellIn date has passed"; +assertEquals(failMessage, 12, quality); +} +@Test +public void testUpdateEndOfDay_AgedBrie_Quality_0_50() { +// Arrange +store.addItem(new Item("Aged Brie", 0, 50) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "The Quality of Aged Brie is never more than 50 increases twice after SellIn date has passed"; +assertEquals(failMessage, 50, quality); +} +@Test +public void testUpdateEndOfDay_AgedBrie_Quality_Minus1_20() { +// Arrange +store.addItem(new Item("Aged Brie", -1, 20) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "The Quality of Aged Brie increases twice after SellIn date has passed"; +assertEquals(failMessage, 22, quality); +} +@Test +public void testUpdateEndOfDay_AgedBrie_SellIn_2_10() { +// Arrange +store.addItem(new Item("Aged Brie", 2, 10) ); +// Act +store.updateEndOfDay(); +// Assert +int sellIn = store.getItems().get(0).getSellIn(); +String failMessage = "SellIn date decreases"; +assertEquals(failMessage, 1, sellIn); +} +@Test +public void testUpdateEndOfDay_AgedBrie_SellIn_1_10() { +// Arrange +store.addItem(new Item("Aged Brie", 1, 10) ); +// Act +store.updateEndOfDay(); +// Assert +int sellIn = store.getItems().get(0).getSellIn(); +String failMessage = "SellIn date decreases"; +assertEquals(failMessage, 0, sellIn); +} +@Test +public void testUpdateEndOfDay_AgedBrie_SellIn_0_10() { +// Arrange +store.addItem(new Item("Aged Brie", 0, 10) ); +// Act +store.updateEndOfDay(); +// Assert +int sellIn = store.getItems().get(0).getSellIn(); +String failMessage = "SellIn date decreases"; +assertEquals(failMessage, -1, sellIn); +} +// Test Sulfuras +@Test +public void testUpdateEndOfDay_Sulfuras_Quality_0_70() { +// Arrange +store.addItem(new Item("Sulfuras, Hand of Ragnaros", 0, 70) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "Quality of Sulfuras is 80 and never alters"; +assertEquals(failMessage, 80, quality); +} +@Test +public void testUpdateEndOfDay_Sulfuras_SellIn_5_80() { +// Arrange +store.addItem(new Item("Sulfuras, Hand of Ragnaros", 5, 80) ); +// Act +store.updateEndOfDay(); +// Assert +int sellIn = store.getItems().get(0).getSellIn(); +String failMessage = "Sulfuras, being a legendary item, never has to be sold"; +assertEquals(failMessage, 5, sellIn); +} +@Test +public void testUpdateEndOfDay_Sulfuras_SellIn_0_80() { +// Arrange +store.addItem(new Item("Sulfuras, Hand of Ragnaros", 0, 80) ); +// Act +store.updateEndOfDay(); +// Assert +int sellIn = store.getItems().get(0).getSellIn(); +String failMessage = "Sulfuras, being a legendary item, never has to be sold"; +assertEquals(failMessage, 0, sellIn); +} +// Test Backstage pass +@Test +public void testUpdateEndOfDay_Backstage_Quality_15_20() { +// Arrange +store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", +15, 20) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "Quality of Backstage pass increases by 1 when there are more than 10 days"; +assertEquals(failMessage, 21, quality); +} +@Test +public void testUpdateEndOfDay_Backstage_Quality_10_20() { +// Arrange +store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", +10, 20) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "Quality of Backstage pass increases by 2 when there are 10 or less days"; +assertEquals(failMessage, 22, quality); +} +@Test +public void testUpdateEndOfDay_Backstage_Quality_8_20() { +// Arrange +store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", +8, 20) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "Quality of Backstage pass increases by 2 when there are 10 or less days"; +assertEquals(failMessage, 22, quality); +} +@Test +public void testUpdateEndOfDay_Backstage_Quality_5_20() { +// Arrange +store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", +5, 20) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "Quality of Backstage pass increases by 3 when there are 5 or less days"; +assertEquals(failMessage, 23, quality); +} +@Test +public void testUpdateEndOfDay_Backstage_Quality_3_20() { +// Arrange +store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", +3, 20) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "Quality of Backstage pass increases by 3 when there are 5 or less days"; +assertEquals(failMessage, 23, quality); +} +@Test +public void testUpdateEndOfDay_Backstage_Quality_0_20() { +// Arrange +store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", +0, 20) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "Quality of Backstage drops to 0 after the concert"; +assertEquals(failMessage, 0, quality); +} +@Test +public void testUpdateEndOfDay_Backstage_Quality_15_50() { +// Arrange +store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", +15, 50) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "The Quality of an item is never more than 50"; +assertEquals(failMessage, 50, quality); +} +@Test +public void testUpdateEndOfDay_Backstage_SellIn_5_10() { +// Arrange +store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", +5, 10) ); +// Act +store.updateEndOfDay(); +// Assert +int sellIn = store.getItems().get(0).getSellIn(); +String failMessage = "The SellIn value should decrease by 1"; +assertEquals(failMessage, 4, sellIn); +} +// Test Elixir +@Test +public void testUpdateEndOfDay_Elixir_Quality_2_7() { +// Arrange +store.addItem(new Item("Elixir of the Mongoose", 2, 7) ); +// Act +store.updateEndOfDay(); +// Assert +int quality = store.getItems().get(0).getQuality(); +String failMessage = "Quality decreases by 1"; +assertEquals(failMessage, 6,quality); +} +@Test +public void testUpdateEndOfDay_SellIn_Quality_2_7() { +// Arrange +store.addItem(new Item("Elixir of the Mongoose", 2, 7) ); +// Act +store.updateEndOfDay(); +// Assert +int sellIn = store.getItems().get(0).getSellIn(); +String failMessage = "SelIn decreases by 1"; +assertEquals(failMessage, 1, sellIn); +} +} \ No newline at end of file From 867c9fd6d83552a25afdd32f6dcce27f7a6fc95b Mon Sep 17 00:00:00 2001 From: Janne Laulajainen Date: Wed, 19 Oct 2016 18:26:56 +0300 Subject: [PATCH 2/6] test commit, was having problems earlier --- src/fi/oulu/tol/sqat/GildedRose.java | 2 +- src/fi/oulu/tol/sqat/Item.java | 2 +- src/fi/oulu/tol/sqat/tests/GildedRoseTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fi/oulu/tol/sqat/GildedRose.java b/src/fi/oulu/tol/sqat/GildedRose.java index 6ab5c7a..2e53641 100644 --- a/src/fi/oulu/tol/sqat/GildedRose.java +++ b/src/fi/oulu/tol/sqat/GildedRose.java @@ -86,7 +86,7 @@ public static void updateEndOfDay() } if ("Sulfuras, Hand of Ragnaros".equals(item.getName())) { - item.setSulfuras();/*if sulfuras, ignore everything above, set sulfuras stats*/ + item.setSulfuras();/*if Sulfuras, ignore everything above, set Sulfuras stats*/ } } } diff --git a/src/fi/oulu/tol/sqat/Item.java b/src/fi/oulu/tol/sqat/Item.java index a8a7562..cb63335 100644 --- a/src/fi/oulu/tol/sqat/Item.java +++ b/src/fi/oulu/tol/sqat/Item.java @@ -39,7 +39,7 @@ public void setSulfuras(){ sellIn = 5; } - /* Generated getter and setter code */ + /* Generated getter and setter codex */ public String getName() { return name; } diff --git a/src/fi/oulu/tol/sqat/tests/GildedRoseTest.java b/src/fi/oulu/tol/sqat/tests/GildedRoseTest.java index 75c4a9b..ab25ceb 100644 --- a/src/fi/oulu/tol/sqat/tests/GildedRoseTest.java +++ b/src/fi/oulu/tol/sqat/tests/GildedRoseTest.java @@ -96,7 +96,7 @@ public void testUpdateEndOfDay_AgedBrie_SellIn_0_10() { String failMessage = "SellIn date decreases"; assertEquals(failMessage, -1, sellIn); } -// Test Sulfuras +// Test Sulfurasx @Test public void testUpdateEndOfDay_Sulfuras_Quality_0_70() { // Arrange From d7d94569ea7d24de4347c3e60a60790efedf77dc Mon Sep 17 00:00:00 2001 From: Janne Laulajainen Date: Wed, 19 Oct 2016 19:58:15 +0300 Subject: [PATCH 3/6] more changes --- bin/fi/oulu/tol/sqat/GildedRose.class | Bin 1813 -> 1813 bytes bin/fi/oulu/tol/sqat/Item.class | Bin 1660 -> 1643 bytes .../oulu/tol/sqat/tests/GildedRoseTest.class | Bin 6286 -> 6072 bytes src/fi/oulu/tol/sqat/GildedRose.java | 3 ++- src/fi/oulu/tol/sqat/Item.java | 6 +++--- .../oulu/tol/sqat/tests/GildedRoseTest.java | 11 ----------- 6 files changed, 5 insertions(+), 15 deletions(-) diff --git a/bin/fi/oulu/tol/sqat/GildedRose.class b/bin/fi/oulu/tol/sqat/GildedRose.class index 3487df6b1ec20ba69e916e22c5a9e5e39dd86f41..d963160cf65e7cf7b95026569a80c1b3901b1bb9 100644 GIT binary patch delta 13 UcmbQrHG6-ZA`zBUo=9cCLmL}$8mQ+q|WK`!; zaM*YeBOfM#vGD|V?PoBUm%B;wsFgcG|adIfL7_$obcg^E1c*O%-Ec z0+LJ&vJ7%S8pKj$-~g&&WKd#Io*c`pIN60+j9CTDHkVap5C_We0M$7&FoSh+YejBh zP?JvC%AhuRBeRYwOt%Iul?fn~Oe_eMnhg9;q8Ind7kHRa`F3Xjc31$lSH(h z2FHy$O~iPow#6Z+nn(2IdVIs)bupb%{8OtD2RP!)EIKG?8}HCp@M~w6Xy@(vEz!ll z^qffZao3(uuONS2bE+fN8n*U@+mnsqgw@hyS#6Cv_3@mmUSzr6NC-J`!H8(w;7zdM zH669o$t7=8G;zLC@*GZ*RUR&xVQqh6wU3%PFJ&lA26dB{(&VEa3Q#Ytq72ngA8n$3 zw)|1iGS5YlC(UKT;IXCBP}FrN?;Q z0MAO3w@Uy22Nv!yf5d~2NG&uC{RE4rvG^$#KgZ%1So{);U#Z1M7IyYWw4?UmZZ&uY z_zj|G5d9X>?-2bS(I3!x7M%n9-D8R#b-|F^6vx;TTVWY7@NRg9)BMXd{!ilA-`RCFh}lcMo~R;w0kZ5kiZ znp6%IsTQe-k42?gg|=vG7Zs@$TJgDvh>xX(EJS=D{&z5%+0Agj```c08LG+F>XW}m zMu})Cb=}d|NwJ(8WWC>mFY56KigG~<@){Z7oU9SMcuZD{Jv=MZ?j}JSxFDn4>uqr# z613iVS?f!=TLsnP#p1lLS+w&OZL2uR16o*|<|%EXILCAKga{2b>I)@L>!y2~&uHLj ze^}eR%G{oa2dR-a`7M5Fn65fH!sF#OKddmt4z9GL++(b?S}8zn6ry%oOew0O4q8TO z{t~qLifxLWSZ8tEGF?fdg7=j#kh|5Ud)Y9pNQQJeLzR@FAa#;WSz1Cls-`YlLFaka zjB(Oj1gI-0_VXNbUZfl50!%l|MVKC#OE8yVdX*6eN+NwFvJdhqWFO=;$m@_dAa6q6 za^yirRt3zmqyuHMI_qKQto_ip$)JAJ9YEc?s5^+d_o$BU<62^(<-e9r(-J)lJpw%p z{Q!CtdJOsz^tjR-vO?SuM6yd+_t8XLb8;sjA45(+K7pKsd*Ykr1nj)`N%z9Px> z*6PR%#B=nVLC+WH`3gN>qvsp+eCzaVE1uMy^x<;<{_W$cY|07EV~ckP%_H Date: Wed, 19 Oct 2016 21:53:52 +0300 Subject: [PATCH 4/6] Aged Brie issue The tests given in the pdf seem to assume that Aged Brie increases by 2 in quality when it goes over the sell in date... this is never specified in the task description --- bin/fi/oulu/tol/sqat/GildedRose.class | Bin 1813 -> 1831 bytes bin/fi/oulu/tol/sqat/Item.class | Bin 1643 -> 1786 bytes src/fi/oulu/tol/sqat/GildedRose.java | 114 ++++++++++++-------------- src/fi/oulu/tol/sqat/Item.java | 7 ++ 4 files changed, 59 insertions(+), 62 deletions(-) diff --git a/bin/fi/oulu/tol/sqat/GildedRose.class b/bin/fi/oulu/tol/sqat/GildedRose.class index d963160cf65e7cf7b95026569a80c1b3901b1bb9..7d7dae6f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/bin/fi/oulu/tol/sqat/Item.class index 4137d41b6c10509228a04644ffc3f60621b27b68..fec0ea27367a2f6b346741e5c226c62c433ef217 100644 GIT binary patch delta 663 zcmaFO^NW}3)W2Q(7#J9g8O%3w)iWCKBxj^1X9pLgCTAw*Ffwpv7Q@;6DXGatsfop@ zfu)H#nI)B+42%rwljkuSFzQS`&uGDDIGKYffl**{CX+7XWF=-LMv2Mw%%Y4clNFhj z8D&81dQ}E-pe7!mea;Nb3`{_pTPt!4gPL^8RtB|=KrR!5G?3&1ODO_rB?cKFUksv@ zL6$)d$OCF(&|u&I8pOz;iOawQEC#A(15H#TV4@ZSKh%kqKqoSSYy&w_n+51ZZFDDU z0u9sx8^{Au3UwkQgYM)y7V#K0EoKy5d_W@^7<3uf81#Ui&_~kA1J|hs6o-Tnhz2=; zRci}_!3H1$5;|;PLF36ES#)9z&|PH4z{+5bkn*z-;o9xXduVIAMEEROKEWl 0) - { - item.decreaseQuality(1); - } + if ("Backstage passes to a TAFKAL80ETC concert".equals(item.getName())) + { + if (item.getSellIn() > 10) + { + if (item.getQuality() < 50) + { + item.increaseQuality(1); + } + } + else if (item.getSellIn() < 11 && item.getSellIn() > 5) + { + if (item.getQuality() < 50) + { + item.increaseQuality(2); + } + } + else if (item.getSellIn() < 6 && item.getSellIn() > 0) + { + if (item.getQuality() < 50) + { + item.increaseQuality(3); + } + } + else if (item.getSellIn() <= 0) + { + item.setQuality(0); + } + } + else if ("Aged Brie".equals(item.getName())) + { + if(item.getQuality() < 50 && item.getSellIn() > 0){ + item.increaseQuality(1); + } + } + + item.decreaseSellIn(); + + if ("Sulfuras, Hand of Ragnaros".equals(item.getName())) + { + item.setSulfuras(); + /*if item is Sulfuras, ignore everything above, set Sulfuras stats*/ + } } - 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.increaseQuality(1); - } - } - - if (item.getSellIn() < 6) - { - if (item.getQuality() < 50) - { - item.increaseQuality(1); - } - } - } - } - } - - item.decreaseSellIn(); - - if (item.getSellIn() < 0) - { - if (!"Aged Brie".equals(item.getName())) - { - if (!"Backstage passes to a TAFKAL80ETC concert".equals(item.getName())) - { - if (item.getQuality() > 0) - { - item.decreaseQuality(1); - } - } - else - { - item.setQuality(item.getQuality() - item.getQuality()); - } - } - else - { - if (item.getQuality() < 50) - { - item.increaseQuality(1); - } - } - } - if ("Sulfuras, Hand of Ragnaros".equals(item.getName())) - { - item.setSulfuras(); - /*if Sulfuras, ignore everything above, set Sulfuras stats*/ + /*otherwise item is normal*/ + else{ + item.decreaseQuality(1); + item.decreaseSellIn(); } } } diff --git a/src/fi/oulu/tol/sqat/Item.java b/src/fi/oulu/tol/sqat/Item.java index 608b4cc..aebbd56 100644 --- a/src/fi/oulu/tol/sqat/Item.java +++ b/src/fi/oulu/tol/sqat/Item.java @@ -20,6 +20,13 @@ public boolean isMaximumQuality(){ public boolean hasZeroQuality(){ return true; } + public boolean checkSpecial(){ + return true; + + } + public boolean isSpecial(){ + return true; + } public void decreaseQuality(int x){ From 66d573973d29144b56f327f3456749f44a68ee4e Mon Sep 17 00:00:00 2001 From: Janne Laulajainen Date: Wed, 19 Oct 2016 22:52:04 +0300 Subject: [PATCH 5/6] added helper methods --- bin/fi/oulu/tol/sqat/GildedRose.class | Bin 1831 -> 1916 bytes bin/fi/oulu/tol/sqat/Item.class | Bin 1786 -> 1932 bytes src/fi/oulu/tol/sqat/GildedRose.java | 31 ++++++++++++++------------ src/fi/oulu/tol/sqat/Item.java | 21 ++++++++++------- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/bin/fi/oulu/tol/sqat/GildedRose.class b/bin/fi/oulu/tol/sqat/GildedRose.class index 7d7dae6f56cc5f38e945cc3b34cecd0678d44133..5c69d59dd0617fb30c3728f7e79409b670294142 100644 GIT binary patch delta 778 zcmX|*%=l48)E1p^DBpsTJ5g6_KM!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`t!9XbxeN=P3K$LSJj#%UdB*yaiq^^{ zRjh?e>=rNSt>1B;p?Qq6z#ig3o-NOz@DlSti89Ad?GIka* zm&i;aA7GYN1?vy0{Y(?utL!UmvnpUoB~S+S3Ig6zfsDR+66hUe%Vgo-O)(D- zxm;QQWi09p5UWUHb_lh26;-P9UW&SkokY!Ol3-tvoI1HP1d&M~7}ZlxC*iXMK8@*> zmsC}Y_g|8s7WS_r4EsVafZ-zE_C08^gq1lIM((B1GJlOS^OD*JG>1`^b04}%!3)-R zP+-3OnwH;GQCC;XsNsDDINLW(0O3UIsFDQSxC!w4F@OyKTK@z1P_><8_=#$Rgkens z!`djrH2~T}DHjrkj6O_Zb`oU`tMWBCS=lQ%{q|W$|8F3xheKFKiuDnFoQP(tobg^{ zO@0H%;Sz5SIZvd{`0ggol8971XRW-Z#%L;AcnsS^+T>EPbICJdvM;5DiG8gK>0myQ71D zz(EsS9Q*Rl^>3i?#UGQ_z_x|OY^?1iEt8jYx0gBcq6sgm)7tjJFwY-c(W9g`@MkJONMIfc z7RYV(*QDB+T%fvh8FsV{xU?p6Pb8dcP((4$!%8NS>vptCOIhO|N;F5y5%Wv*ll1b^ vk6pZVeowrf6K)W1lX#P<<-VL`H)o4ayEBoVt!)#hVEf|NZjXCKe0=pA^Tu9P diff --git a/src/fi/oulu/tol/sqat/GildedRose.java b/src/fi/oulu/tol/sqat/GildedRose.java index 8282346..e8d79e3 100644 --- a/src/fi/oulu/tol/sqat/GildedRose.java +++ b/src/fi/oulu/tol/sqat/GildedRose.java @@ -25,59 +25,62 @@ public static void updateEndOfDay() { Item item = items.get(i); - /*if item is 'special'*/ - - if ("Backstage passes to a TAFKAL80ETC concert".equals(item.getName()) - || "Aged Brie".equals(item.getName()) - || "Sulfuras, Hand of Ragnaros".equals(item.getName())) + if (item.isSpecial()) { if ("Backstage passes to a TAFKAL80ETC concert".equals(item.getName())) { if (item.getSellIn() > 10) { - if (item.getQuality() < 50) + if (!item.isMaximumQuality()) { item.increaseQuality(1); } } else if (item.getSellIn() < 11 && item.getSellIn() > 5) { - if (item.getQuality() < 50) + if (!item.isMaximumQuality()) { item.increaseQuality(2); } } else if (item.getSellIn() < 6 && item.getSellIn() > 0) { - if (item.getQuality() < 50) + if (!item.isMaximumQuality()) { item.increaseQuality(3); } } - else if (item.getSellIn() <= 0) + else if (item.HasExpired()) { item.setQuality(0); } } else if ("Aged Brie".equals(item.getName())) { - if(item.getQuality() < 50 && item.getSellIn() > 0){ + if(!item.isMaximumQuality() && item.getSellIn() > 0){ item.increaseQuality(1); - } + }else if (!item.isMaximumQuality() && item.getSellIn() <= 0){ + item.increaseQuality(2); + } } item.decreaseSellIn(); - if ("Sulfuras, Hand of Ragnaros".equals(item.getName())) + if ("Sulfuras, Hand of Ragnaros".equals(item.getName()))/*if item is Sulfuras, ignore everything above, set Sulfuras stats*/ { item.setSulfuras(); - /*if item is Sulfuras, ignore everything above, set Sulfuras stats*/ + } } /*otherwise item is normal*/ - else{ + else{ + if (item.getSellIn() > 0){ item.decreaseQuality(1); item.decreaseSellIn(); + }else if (item.getSellIn() <= 0){ + item.decreaseQuality(2); + item.decreaseSellIn(); + } } } } diff --git a/src/fi/oulu/tol/sqat/Item.java b/src/fi/oulu/tol/sqat/Item.java index aebbd56..6592a53 100644 --- a/src/fi/oulu/tol/sqat/Item.java +++ b/src/fi/oulu/tol/sqat/Item.java @@ -12,21 +12,25 @@ public Item(String name, int sellIn, int quality) { this.setQuality(quality); } public boolean HasExpired (){ - return true; + if (sellIn<=0){ + return true;} + else return false; } public boolean isMaximumQuality(){ - return true; + if (quality >= 50){ + return true;} + else return false; } public boolean hasZeroQuality(){ return true; } - public boolean checkSpecial(){ - return true; - - } public boolean isSpecial(){ - return true; - } + if (name=="Backstage passes to a TAFKAL80ETC concert" + || name == "Aged Brie" + || name == "Sulfuras, Hand of Ragnaros") + {return true;} + else return false; +} public void decreaseQuality(int x){ @@ -38,6 +42,7 @@ public void increaseQuality(int x){ } public void decreaseSellIn(){ + /*sellIn only ever decreases by 1*/ sellIn = sellIn - 1; } From 32da3f78bf6aeb7cc977ec75fed31d4dac41be2c Mon Sep 17 00:00:00 2001 From: Janne Laulajainen Date: Wed, 19 Oct 2016 23:03:25 +0300 Subject: [PATCH 6/6] final edits --- bin/fi/oulu/tol/sqat/GildedRose.class | Bin 1916 -> 1915 bytes bin/fi/oulu/tol/sqat/Item.class | Bin 1932 -> 1942 bytes src/fi/oulu/tol/sqat/GildedRose.java | 12 ++++++------ src/fi/oulu/tol/sqat/Item.java | 8 ++++++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/bin/fi/oulu/tol/sqat/GildedRose.class b/bin/fi/oulu/tol/sqat/GildedRose.class index 5c69d59dd0617fb30c3728f7e79409b670294142..a865aef0e603ca5bd0a5a932a1ad71542f1f68e3 100644 GIT binary patch delta 299 zcmX|+F-t;W6o#Msl~>ca#z&|L1}zQU29Y$%N-!db%4%rJY6%)@auFPaAOb-UE(Auj zD2Q7)T&N|XAJ7oAwKUk;(vSu9U86X|dEWQo4Cl-EG_FgoVh5oHZJ;mNpxa_Fe8ae) z&BUr{Gg+lAqY7d+i7JPRl0)7)QbFp1ve|EwZgBeB*9be{`S-`BtLG1Tb&U~cU;SNY zOx?D;dPRI=UFzxL5m9o)$TLNOI44YV#tbE9IcJVK^E6rDmK1j^a?cVEEc3_;Ppt9G zIxl4Cu)!OfytBmzAIRY~$ngi$nhRSM#>vTomS#2AwS*~KrE*i%BV F{{tVbL=FG| delta 299 zcmX|+%_~G<6o;StGIz#Y-O-x{Q>JVzT#IS)5re6blrUIWjgOVGU}dA!ER;kk-Gzp- zm}tsM7Pn+W`2#GJosGrV+E~m8=iZ{Td4A{V)cMuzFZ=o+RIH+8Frp2a3iTVB6Ss6L z?&+C!JbFt!=#)U(W1z&kP^Kk%ffmS~a^y664BnHcp+OXV0*lJDMT{^C7#FU5? H5sKAcT^&S& diff --git a/bin/fi/oulu/tol/sqat/Item.class b/bin/fi/oulu/tol/sqat/Item.class index b102cf0fc383582a8b6c7450662f328c0facabd2..252be287adfaf04214c8076e6981ed868316c9aa 100644 GIT binary patch delta 221 zcmXAh%?bf=6vfZq{O^DAQDcxvKJqbA3N?yZ5D_V}qP&D>@Bqs0mW`FYg#}x0Vd-7m zSlrV+zs@-)=j_~H)^>v!6o72|fo3|mBH2y{Pc-$-x(T*W6wN@3<`7374m`Lhpd=*q zucC~KxQ3hs<+80?s>D6LbE{IRNxd#J4T<@D))Du~XG0z8Ab~E26j2~wpN}+;4`47v r5+T27q(+=EW14_4<&W`rZ+dFR7hwxwOJPg3V&5LqT72}&9Bk(c<*g!l delta 211 zcmXBNyAA5#LQnwW?K_&O-WjB?##O*TNpeCekVOPJSjfYcF7`h_85Qa3 z5(bpTY28vq9_dZmmi00+GA^MiuNt3pKutv9@LLD`(hc5Hhg^{^GtDDCnCQy~1AdaH khHRTYjY05u7cTJL?5YW0#HM1ipMAs@?1p_>imk+)FZm`R)Bpeg diff --git a/src/fi/oulu/tol/sqat/GildedRose.java b/src/fi/oulu/tol/sqat/GildedRose.java index e8d79e3..fde36b1 100644 --- a/src/fi/oulu/tol/sqat/GildedRose.java +++ b/src/fi/oulu/tol/sqat/GildedRose.java @@ -25,7 +25,7 @@ public static void updateEndOfDay() { Item item = items.get(i); - if (item.isSpecial()) + if (item.isSpecial())/*item string is in 'special item' list*/ { if ("Backstage passes to a TAFKAL80ETC concert".equals(item.getName())) { @@ -36,14 +36,14 @@ public static void updateEndOfDay() item.increaseQuality(1); } } - else if (item.getSellIn() < 11 && item.getSellIn() > 5) + else if (item.getSellIn() <= 10 && item.getSellIn() > 5) { if (!item.isMaximumQuality()) { item.increaseQuality(2); } } - else if (item.getSellIn() < 6 && item.getSellIn() > 0) + else if (item.getSellIn() <= 5 && item.getSellIn() > 0) { if (!item.isMaximumQuality()) { @@ -81,9 +81,9 @@ else if ("Aged Brie".equals(item.getName())) item.decreaseQuality(2); item.decreaseSellIn(); } - } - } - } + } + } + } } diff --git a/src/fi/oulu/tol/sqat/Item.java b/src/fi/oulu/tol/sqat/Item.java index 6592a53..15077f2 100644 --- a/src/fi/oulu/tol/sqat/Item.java +++ b/src/fi/oulu/tol/sqat/Item.java @@ -17,14 +17,18 @@ public boolean HasExpired (){ else return false; } public boolean isMaximumQuality(){ - if (quality >= 50){ - return true;} + if (quality >= 50) + { + quality = 50; + return true; + } else return false; } public boolean hasZeroQuality(){ return true; } public boolean isSpecial(){ + /*lists some special items*/ if (name=="Backstage passes to a TAFKAL80ETC concert" || name == "Aged Brie" || name == "Sulfuras, Hand of Ragnaros")