From 2536c99a4915c36df43b81705aed39fa679a3af7 Mon Sep 17 00:00:00 2001 From: anrehman Date: Fri, 9 Sep 2016 16:32:57 +0300 Subject: [PATCH 1/3] Added Some tests to check the requirements of the code --- bin/.gitignore | 1 + bin/fi/oulu/tol/sqat/GildedRose.class | Bin 2380 -> 2131 bytes bin/fi/oulu/tol/sqat/Item.class | Bin 1034 -> 1034 bytes .../oulu/tol/sqat/tests/GildedRoseTest.class | Bin 504 -> 2756 bytes .../oulu/tol/sqat/tests/GildedRoseTest.java | 89 +++++++++++++++++- 5 files changed, 88 insertions(+), 2 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..b904cd2a2f60ff47b023e9e0b84ddbe56eddc526 100644 GIT binary patch literal 2131 zcmbVMOK%%h6#nkmi60qa*C}amn|9Jbu$vHv7D7{p7RPxuu0!g`sD(vu?6Es#Vkh$e zr9wgic3q&h3q*w~5fUv69~hLv6^Zw z!ISZ;q=)9k*i~4gBU|X#spp`g$N?cH>hie zpEkfj$ytV0DJO$8k8k?$M$@>}d@?45I^F7)&2`g{vou&UyzrrE@v^FHa??~z#i}Y? zSxe0?r!r?J=GM|mp;{@Z25of==VT-?%@8CCtAwFh+s=?J`9aeb&Dna%Hn=&aEb>ZG zsg{(>oJQEFnj-lf87a(Avgu0pk`j60os}^spaTS*Q+0i*BCHEC7DY~ga%xr~=0zFH zBGzkaH%SJj(X&M3owH~&m-uFVeuKHHZ4}gbO-y*GF=gYTkr<)_;i1z@gv6}1L{Kl*T({M3E))4wR2CM=2GJ(N4Tha(c+YZMPUt}t;tLkNGv~>qNor&CX7jmx~-MQ{IyVn%b@>y%=bLssBSd`HAKzG2me}62FiN`sk zH|Y?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}M diff --git a/bin/fi/oulu/tol/sqat/Item.class b/bin/fi/oulu/tol/sqat/Item.class index 478a73984862181a0a6b22a57fca5a1788d6a3f6..86c608e1a130d3506ba1bc783f500e2d34d0181d 100644 GIT binary patch delta 30 gcmeC;=;GLLiBXV&ft7)c0R-3?I6&0q$BgPs08#Y>lK=n! delta 30 jcmeC;=;GLLiBXV|ft7)cfq{XMft`T^L~nk~sLlicQXd4C diff --git a/bin/fi/oulu/tol/sqat/tests/GildedRoseTest.class b/bin/fi/oulu/tol/sqat/tests/GildedRoseTest.class index e44e81ce2b232358b6069c215dc740c0984c2b8c..36246cced0deb1b75d80a7f53ee2a0e3f31de341 100644 GIT binary patch literal 2756 zcmb`H+gB4;6vn>+VnT>DB8Z~W0kkH7Bw#HF6b&~;Bi9s5S6kMQ9Kzr*gENyVtCzR_ zG3`TF`vSJE)z#ZmJ0jZ!p>;hhEUL+wz8VBq1n28_y25hcXda>?esq? zW>P_17Wv6RPIJY)nOokO(+;;%d6Ap3b+NTt&hhgGohKx*l8`KDTWryD@ zRCPh->W|{Xp?MCns#uP-f;@kX7D#j`U zu_sTYjRKBq+4Rbd+76ruK^Fvck1l$ejqEZc1z_82vlRQN;BvJW4-ZOyJl(9R1}Ual z#E7)wNm*O#!Z7CO%N5NLIlmusB5Mozo_VEbMF=xId*0Ar>$Ym`sP3*%pIK(!;;@xE z8{#lY1P;Zi{C>)`aGcDpW)^#wvF;^HJ4Y4toZ7NpFm?*I=J;DfcuISf{v1*tYi3T? zv8Lrs&9G9-z zW>(EwW|rcY@<$Zhd`JF!GJR?Nc?HAoSfAQ)g`L?Iv))NG<+@d{vtmJ)-=0e+GG!>* zu=G8rh;A*qIm9P^wRjEkJ;A%edtl%gpz|fr| z41fOyqw?tH;?X_DblnKy8m^#+*IuaT!yx)OPB)7s4R}ZSC51>aj{7W4MHeP8$?^sn zo5IJ;InB%x!HYd$Ou@st2tWG>6V(W*N`$%;v$Yg`tRIN;IzWm$q!=bkk_;n!8fCS2 zD@Z2FB%?k_f0<;MvH2WePT=z;{hA_knK%TjF}3A zu`)t^F{%+N#aR3|2v3@$D`z028zDR*!eb&lCBhOBmWi-Jgw_8AVW}>{kG`MAtNpYb z4WBs^tBn{o$nYFj@foh;b56w<7{Zqr!&U{ucv*&|@1)+clZI-XA(1 pP=C##{)R*SEv5Lbf}>W7esubur(u5TswcvWc~U&*r=tm<{tcB-8OQ(t delta 167 zcmX>i`h%J4)W2Q(7#J9g86+oi?dIhvNi8l3$w&<;DlN&F_+H{MWH(lA yJ7We$AY@=*W!b?XxDm);V&DRjTtFH`vM_K1Ap-*sL=lkY1@agf#DOFeg9HFt4 items = store.getItems(); + Item item = items.get(0); + assertEquals(8, item.getQuality()); + } + + @Test + public void testGildedRose_QualityLessThanEqualTo50() { + // Arrange + GildedRose store = new GildedRose(); + store.addItem(new Item("Aged Brie", 2, 50) ); + + // Act + store.updateEndOfDay(); + + // Assert + List items = store.getItems(); + Item item = items.get(0); + assertEquals(50, item.getQuality()); + } + + @Test + public void testGildedRose_SulfurasQuality() { + // Arrange + GildedRose store = new GildedRose(); + store.addItem(new Item("Sulfuras, Hand of Ragnaros", 0, 80) ); + + // Act + store.updateEndOfDay(); + + // Assert + List items = store.getItems(); + Item item = items.get(0); + assertEquals(80, item.getQuality()); + } + + @Test + public void testGildedRose_BackstageQuality10days() { + // Arrange + GildedRose store = new GildedRose(); + store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", 10, 10) ); + + // Act + store.updateEndOfDay(); + // Assert + List items = store.getItems(); + Item item = items.get(0); + assertEquals(12, item.getQuality()); + } + + @Test + public void testGildedRose_BackstageQuality5days() { + // Arrange + GildedRose store = new GildedRose(); + store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", 5, 10) ); + + // Act + store.updateEndOfDay(); + // Assert + List items = store.getItems(); + Item item = items.get(0); + assertEquals(13, item.getQuality()); + } + + + @Test + public void testGildedRose_BackstageQualityAfterTheConcert() { + // Arrange + GildedRose store = new GildedRose(); + store.addItem(new Item("Backstage passes to a TAFKAL80ETC concert", 1, 10) ); + + // Act + store.updateEndOfDay(); + store.updateEndOfDay(); + + // Assert + List items = store.getItems(); + Item item = items.get(0); + assertEquals(0, item.getQuality()); } } From 8574756a61d847d9388e78d5737e932ead114a06 Mon Sep 17 00:00:00 2001 From: anrehman Date: Tue, 18 Oct 2016 19:54:44 +0400 Subject: [PATCH 2/3] Assignment 5 - SQAT By Aniqa Rehman --- .classpath | 14 +-- .settings/org.eclipse.jdt.core.prefs | 22 ++-- bin/.gitignore | 1 - bin/fi/oulu/tol/sqat/GildedRose.class | Bin 2131 -> 2152 bytes bin/fi/oulu/tol/sqat/Item.class | Bin 1034 -> 1893 bytes .../oulu/tol/sqat/tests/GildedRoseTest.class | Bin 2756 -> 2756 bytes src/fi/oulu/tol/sqat/GildedRose.java | 113 ++++++------------ src/fi/oulu/tol/sqat/Item.java | 60 ++++++++-- .../oulu/tol/sqat/tests/GildedRoseTest.java | 1 - 9 files changed, 107 insertions(+), 104 deletions(-) delete mode 100644 bin/.gitignore diff --git a/.classpath b/.classpath index 72c2ba6..2d74975 100644 --- a/.classpath +++ b/.classpath @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 7341ab1..54e493c 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,11 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/bin/.gitignore b/bin/.gitignore deleted file mode 100644 index 76b3e7b..0000000 --- a/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/fi/ diff --git a/bin/fi/oulu/tol/sqat/GildedRose.class b/bin/fi/oulu/tol/sqat/GildedRose.class index b904cd2a2f60ff47b023e9e0b84ddbe56eddc526..513dd7159b950fd06a82df66af82481d98d56ebe 100644 GIT binary patch literal 2152 zcmaJ>T~`xV6x|b$gk%I76qRb5(hrlM2GpuG)H;NKDKWuJfQq%#OEQGfVS+Q0F8wLm zH(z}1$68q1wYvJ;mp=9H)b2Y8Ns!vCHJLf*+_TR{e*GQ5MeKwTQtp7I8SjzsGfS3TH|v$AXNEDTVC;eTPGoH1G&1GQ2WHJza7te-F0NKI-MFQd7L4+u zQPGx4TBWQjh!=b3b>Fp|MpnVmT+{J<;rMI9ZkZ7bE11+<_EyUk-nqmr;nWk&twcpM z9N{)S1;g4>e!-Zp6!Hn3R3f0ZdtGLfU%?qV|xX8)jlxc%JDc{ANNV`i>`RO{ZqMOlwrn7mG%rWUOh$)x2>< zfl?S?sfJjDgQnS8sgEf*V)^C{36Hh2Zuyp-DO#S-oQHLb>G&;Il77QHS3Fep0)etO z=ogu**_LDZHxvvcQ)>zabIrOr3U~4ny}Y|Ye~7I zj5JJNqLN-b`6dG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ju9RAK=ab7A6mHYvPPJm@DL!@b16uzSTPb diff --git a/bin/fi/oulu/tol/sqat/Item.class b/bin/fi/oulu/tol/sqat/Item.class index 86c608e1a130d3506ba1bc783f500e2d34d0181d..6f834384a72ebc4adfc8f0bdb5d586be911e3164 100644 GIT binary patch literal 1893 zcmaKs+j7%Z6o!AV8FmVkpS& zcHO>bx?aa?^iR?V_6N88( zZYoe+vtucktG@GUcs<)ax}_k|w;acC6(nB{OvmScl>VwXq)!Q=<9lxe-%XFG%&z5-*RJ~)nPyK4-5wYmx(a3J0P@JwY#r4-U z!+IeBB&+bwx(dWG~5szd_;<2$%)gVh<6N_VVz6?Vqh!tKe?tGAH^Zf53qUnNYr}*9 ztw?h-BHG)`7H~peKY{*EH0?*vQFp~BEDf{9a*04r!I!uau)-pxH-v^oRwG6DBRg<4QeuZ4C-Av(za?^h+g@S2me>eaLw0k)ZhynAo=$2G6r_N&wY1|C)GUL|bCmj@jpQE&3Mv8uo8TCzE&LUj(9ja~fL%17( z3aXZ068|{?^8tHGm|0=YZvGZY-6ioJGN^>8+5hilhLr6wHEde?HIix2^gD9D4>3nY MhfMF%ErxI30#^nAlmGw# literal 1034 zcmZ{i&2G~`6otXQ6{QmRv7l7w@s-q&%_z=2D7G-XlMDF6!PhBq!W;!&1 z-3$Md??!$+b>ECHf=Mc%#r`Z1*dJUk4byoTPhSYs7eN$xv4HRd^vleT!t^uKFT*%Y z&jecbW|!ynMpS*3ybnxNv2DS`jzHD!jZ6saS=h$`)fPc|uACbsB6)4YLK7_kgSEqg zM6;%4Z24NhWXR~oIf9H=QwXbC2MBn$E{6XnSapU@Q zMR#cTHuq@I|AB=X>V#wI3XYrf6GkN&v zvZl(5lpnSEhtyFc8&yP6+-9A{C_)7q$3y1_ww(SFyUy{FQD=!e-~)Y%DF~l$8Hl|Oazc>q4IuJrB#5K7-v0|-cZ_KO diff --git a/bin/fi/oulu/tol/sqat/tests/GildedRoseTest.class b/bin/fi/oulu/tol/sqat/tests/GildedRoseTest.class index 36246cced0deb1b75d80a7f53ee2a0e3f31de341..a78509e0383aaaba0cbd5118a3ce9660694787b7 100644 GIT binary patch delta 257 zcmW-bze+-39ERT@?K4^hKkG>4QXKQBL&pd!hZKVTED55uScxeO2?lgP z8=9QD7jGeYkl*+|&-;6)$!XI3{(b*QDt(zsY+=RKVqd2gL+nEw&~Zq|5gk=Jj@@MG*47~E5GN3) z5N8nQ5Epae!Q9zPh=#11T2qS^ZT?*;)U}(L$aY9?@Vodu{CoU9{s4dCJ(3PdpGZe6 S9JBD5g)jK8_?~-T4*mhzPA;eb delta 257 zcmW;GJxjt-9L4b?q+JC^p%4Krlu%kp6|~_# zgK4)Ec=J+-O~f{02e(U}<(E@YdG`^R*nLD1aez4DMu{6`ZdABYb<^dhJw}`$P7!rP z1965pUx==Guos9+SzRfrYnI$-OSjt7o%=Hrdr#V=|49Fdev5vaeuw_l>yh?J2c$z5 RzOZn_!dLoZ`ks3aW#;n%F5LhC diff --git a/src/fi/oulu/tol/sqat/GildedRose.java b/src/fi/oulu/tol/sqat/GildedRose.java index 24741c6..06fac8c 100644 --- a/src/fi/oulu/tol/sqat/GildedRose.java +++ b/src/fi/oulu/tol/sqat/GildedRose.java @@ -3,15 +3,19 @@ import java.util.ArrayList; import java.util.List; - public class GildedRose { + private static final String SULFURAS_HAND_OF_RAGNAROS = "Sulfuras, Hand of Ragnaros"; + private static final String AGED_BRIE = "Aged Brie"; + private static final String BACKSTAGE_PASSES_TO_A_TAFKAL80ETC_CONCERT = "Backstage passes to a TAFKAL80ETC concert"; + private static final int SELL_IN_VALUE_6 = 6; + private static final int SELL_IN_VALUE_11 = 11; private static List items = null; public List getItems() { return items; } - + public void addItem(Item item) { items.add(item); } @@ -19,80 +23,39 @@ public void addItem(Item item) { public GildedRose() { items = new ArrayList(); } - 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())) - { - if (items.get(i).getQuality() > 0) - { - if (!"Sulfuras, Hand of Ragnaros".equals(items.get(i).getName())) - { - items.get(i).setQuality(items.get(i).getQuality() - 1); - } - } - } - else - { - if (items.get(i).getQuality() < 50) - { - items.get(i).setQuality(items.get(i).getQuality() + 1); - - if ("Backstage passes to a TAFKAL80ETC concert".equals(items.get(i).getName())) - { - if (items.get(i).getSellIn() < 11) - { - if (items.get(i).getQuality() < 50) - { - items.get(i).setQuality(items.get(i).getQuality() + 1); - } - } - if (items.get(i).getSellIn() < 6) - { - if (items.get(i).getQuality() < 50) - { - items.get(i).setQuality(items.get(i).getQuality() + 1); - } - } - } - } - } - - if (!"Sulfuras, Hand of Ragnaros".equals(items.get(i).getName())) - { - items.get(i).setSellIn(items.get(i).getSellIn() - 1); - } + public static void updateEndOfDay() { + for (Item item : items) { + if (!SULFURAS_HAND_OF_RAGNAROS.equals(item.getName())) { + item = changeQuality(item); + item.decreaseSellIn(); + if (item.isExpired()) { + item = changeQuality(item); + } + } + } + } - if (items.get(i).getSellIn() < 0) - { - if (!"Aged Brie".equals(items.get(i).getName())) - { - if (!"Backstage passes to a TAFKAL80ETC concert".equals(items.get(i).getName())) - { - if (items.get(i).getQuality() > 0) - { - if (!"Sulfuras, Hand of Ragnaros".equals(items.get(i).getName())) - { - items.get(i).setQuality(items.get(i).getQuality() - 1); - } - } - } - else - { - items.get(i).setQuality(items.get(i).getQuality() - items.get(i).getQuality()); - } - } - else - { - if (items.get(i).getQuality() < 50) - { - items.get(i).setQuality(items.get(i).getQuality() + 1); - } - } - } - } - } + private static Item changeQuality(Item item) { + if (AGED_BRIE.equals(item.getName())) { + item.increaseQuality(); + } else if (BACKSTAGE_PASSES_TO_A_TAFKAL80ETC_CONCERT.equals(item + .getName())) { + if (item.isExpired()) { + item.setQuality(item.getQuality() - item.getQuality()); + } else { + item.increaseQuality(); + if (item.getSellIn() < SELL_IN_VALUE_11) { + item.increaseQuality(); + } + if (item.getSellIn() < SELL_IN_VALUE_6) { + item.increaseQuality(); + } + } + } else { + item.decreaseQuality(); + } + return item; + } } diff --git a/src/fi/oulu/tol/sqat/Item.java b/src/fi/oulu/tol/sqat/Item.java index 447b7fe..df649c2 100644 --- a/src/fi/oulu/tol/sqat/Item.java +++ b/src/fi/oulu/tol/sqat/Item.java @@ -1,35 +1,77 @@ package fi.oulu.tol.sqat; - public class Item { - String name; - int sellIn; - int quality; - - public Item(String name, int sellIn, int quality) { + private static final int INCREMENT_VALUE = 1; + private static final int DECREMENT_VALUE = 1; + private static final int MINIMUM_SELL_IN = 0; + private static final int MINIMUM_QUALITY = 0; + private static final int MAXIMUM_QUALITY = 50; + String name; + int sellIn; + int quality; + + public Item(String name, int sellIn, int quality) { this.setName(name); this.setSellIn(sellIn); this.setQuality(quality); } - + /* Generated getter and setter code */ - public String getName() { + public String getName() { return name; } + public void setName(String name) { this.name = name; } + public int getSellIn() { return sellIn; } + public void setSellIn(int sellIn) { this.sellIn = sellIn; } + public int getQuality() { return quality; } + public void setQuality(int quality) { this.quality = quality; } -} + public void increaseQuality() { + if (!hasReachedMaximumQuality()) { + this.quality = this.quality + INCREMENT_VALUE; + } + } + + public void decreaseQuality() { + if (!hasZeroQuality()) { + this.quality = this.quality - DECREMENT_VALUE; + } + } + + public void decreaseSellIn() { + this.sellIn = this.sellIn - DECREMENT_VALUE; + } + + public boolean hasZeroQuality() { + if (this.quality == MINIMUM_QUALITY) + return true; + return false; + } + + public boolean hasReachedMaximumQuality() { + if (this.quality == MAXIMUM_QUALITY) + return true; + return false; + } + + public boolean isExpired() { + if (this.sellIn < MINIMUM_SELL_IN) + return true; + return false; + } +} diff --git a/src/fi/oulu/tol/sqat/tests/GildedRoseTest.java b/src/fi/oulu/tol/sqat/tests/GildedRoseTest.java index 99ed999..ebc5956 100644 --- a/src/fi/oulu/tol/sqat/tests/GildedRoseTest.java +++ b/src/fi/oulu/tol/sqat/tests/GildedRoseTest.java @@ -2,7 +2,6 @@ import static org.junit.Assert.*; -import java.util.ArrayList; import java.util.List; import org.junit.Test; From 9822b74e20869d1bdb53a52a280fe8eda3b4bfa9 Mon Sep 17 00:00:00 2001 From: anrehman Date: Tue, 18 Oct 2016 19:59:17 +0400 Subject: [PATCH 3/3] Assignment 5 - SQAT Complete By Aniqa Rehman --- bin/fi/oulu/tol/sqat/GildedRose.class | Bin 2152 -> 2152 bytes src/fi/oulu/tol/sqat/GildedRose.java | 1 - src/fi/oulu/tol/sqat/Item.java | 1 + 3 files changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/fi/oulu/tol/sqat/GildedRose.class b/bin/fi/oulu/tol/sqat/GildedRose.class index 513dd7159b950fd06a82df66af82481d98d56ebe..74f547bc33e1fccf9bfd2762fbc5197efefb1bab 100644 GIT binary patch delta 77 zcmaDM@Iqk2Uv@`z1|9|t1_1_51~CRL21y_-1El2{v>DVGbQp{obQ#PT^cbud^ckEP b3>e%Qj2Hrdq9H)ha0YXRXa>v4b{tv&=1~hN delta 77 zcmaDM@Iqk2Uv@_g1|9}Y1_1^w1~CS021y_-1El2{bQshabQz2p^cc(-^ck!e3>cgl c3>n;kA^{903?U5W4B-qG4ABf$lkGUP0O-aGIsgCw diff --git a/src/fi/oulu/tol/sqat/GildedRose.java b/src/fi/oulu/tol/sqat/GildedRose.java index 06fac8c..f7915a4 100644 --- a/src/fi/oulu/tol/sqat/GildedRose.java +++ b/src/fi/oulu/tol/sqat/GildedRose.java @@ -35,7 +35,6 @@ public static void updateEndOfDay() { } } } - private static Item changeQuality(Item item) { if (AGED_BRIE.equals(item.getName())) { item.increaseQuality(); diff --git a/src/fi/oulu/tol/sqat/Item.java b/src/fi/oulu/tol/sqat/Item.java index df649c2..1035528 100644 --- a/src/fi/oulu/tol/sqat/Item.java +++ b/src/fi/oulu/tol/sqat/Item.java @@ -74,4 +74,5 @@ public boolean isExpired() { return true; return false; } + }