Adjust checkstyle rules. Make checkstyle fail the build when violations are found. Correct all current checkstyle violations.
This commit is contained in:
@ -20,28 +20,28 @@ public class App {
|
||||
public static void main(String[] args) {
|
||||
TreasureChest chest = new TreasureChest();
|
||||
|
||||
ItemIterator ringIterator = chest.Iterator(ItemType.RING);
|
||||
ItemIterator ringIterator = chest.iterator(ItemType.RING);
|
||||
while (ringIterator.hasNext()) {
|
||||
System.out.println(ringIterator.next());
|
||||
}
|
||||
|
||||
System.out.println("----------");
|
||||
|
||||
ItemIterator potionIterator = chest.Iterator(ItemType.POTION);
|
||||
ItemIterator potionIterator = chest.iterator(ItemType.POTION);
|
||||
while (potionIterator.hasNext()) {
|
||||
System.out.println(potionIterator.next());
|
||||
}
|
||||
|
||||
System.out.println("----------");
|
||||
|
||||
ItemIterator weaponIterator = chest.Iterator(ItemType.WEAPON);
|
||||
ItemIterator weaponIterator = chest.iterator(ItemType.WEAPON);
|
||||
while (weaponIterator.hasNext()) {
|
||||
System.out.println(weaponIterator.next());
|
||||
}
|
||||
|
||||
System.out.println("----------");
|
||||
|
||||
ItemIterator it = chest.Iterator(ItemType.ANY);
|
||||
ItemIterator it = chest.iterator(ItemType.ANY);
|
||||
while (it.hasNext()) {
|
||||
System.out.println(it.next());
|
||||
}
|
||||
|
@ -12,6 +12,9 @@ public class TreasureChest {
|
||||
|
||||
private List<Item> items;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public TreasureChest() {
|
||||
items = new ArrayList<>();
|
||||
items.add(new Item(ItemType.POTION, "Potion of courage"));
|
||||
@ -26,10 +29,13 @@ public class TreasureChest {
|
||||
items.add(new Item(ItemType.WEAPON, "Dagger of poison"));
|
||||
}
|
||||
|
||||
ItemIterator Iterator(ItemType type) {
|
||||
return new TreasureChestItemIterator(this, type);
|
||||
ItemIterator iterator(ItemType itemType) {
|
||||
return new TreasureChestItemIterator(this, itemType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all items
|
||||
*/
|
||||
public List<Item> getItems() {
|
||||
ArrayList<Item> list = new ArrayList<>();
|
||||
list.addAll(items);
|
||||
|
@ -13,6 +13,9 @@ public class TreasureChestItemIterator implements ItemIterator {
|
||||
private int idx;
|
||||
private ItemType type;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public TreasureChestItemIterator(TreasureChest chest, ItemType type) {
|
||||
this.chest = chest;
|
||||
this.type = type;
|
||||
|
@ -60,7 +60,7 @@ public class TreasureChestTest {
|
||||
@Test
|
||||
public void testIterator() {
|
||||
final TreasureChest chest = new TreasureChest();
|
||||
final ItemIterator iterator = chest.Iterator(expectedItem.getType());
|
||||
final ItemIterator iterator = chest.iterator(expectedItem.getType());
|
||||
assertNotNull(iterator);
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
|
Reference in New Issue
Block a user