mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
improve the if statement
improve the If statement to a switch
This commit is contained in:
parent
e04bd79518
commit
b05de45437
@ -57,8 +57,8 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
<source>18</source>
|
||||
<target>18</target>
|
||||
<compilerArgs>--enable-preview</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
@ -4,19 +4,18 @@ public class StorageItem {
|
||||
protected Item item;
|
||||
|
||||
public static StorageItem createItem(Item item) {
|
||||
if (item.name.equals(AgeddBrie.NAME)) {
|
||||
return new AgeddBrie(item);
|
||||
switch (item.name) {
|
||||
case AgeddBrie.NAME:
|
||||
return new AgeddBrie(item);
|
||||
case BackstagePasses.NAME:
|
||||
return new BackstagePasses(item);
|
||||
case Sulfuras.NAME:
|
||||
return new Sulfuras(item);
|
||||
case Conjured.NAME:
|
||||
return new Conjured(item);
|
||||
case default:
|
||||
return new StorageItem(item);
|
||||
}
|
||||
if (item.name.equals(BackstagePasses.NAME)) {
|
||||
return new BackstagePasses(item);
|
||||
}
|
||||
if (item.name.equals(Sulfuras.NAME)) {
|
||||
return new Sulfuras(item);
|
||||
}
|
||||
if (item.name.equals(Conjured.NAME)) {
|
||||
return new Conjured(item);
|
||||
}
|
||||
return new StorageItem(item);
|
||||
}
|
||||
|
||||
public StorageItem(Item item) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user