Skip to content

Commit

Permalink
Add java 11 (iluwatar#1049)
Browse files Browse the repository at this point in the history
  • Loading branch information
leonmak authored and iluwatar committed Oct 27, 2019
1 parent 63fb8dc commit 6bb3438
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 43 deletions.
6 changes: 1 addition & 5 deletions dao/src/main/java/com/iluwatar/dao/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ public static List<Customer> generateSampleCustomers() {
final Customer customer1 = new Customer(1, "Adam", "Adamson");
final Customer customer2 = new Customer(2, "Bob", "Bobson");
final Customer customer3 = new Customer(3, "Carl", "Carlson");
final List<Customer> customers = new ArrayList<>();
customers.add(customer1);
customers.add(customer2);
customers.add(customer3);
return customers;
return List.of(customer1, customer2, customer3);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
Expand Down Expand Up @@ -59,11 +58,11 @@ public class App {
*/
public static void main(String[] args) {
// initialize game objects and print their status
List<GameObject> objects = new ArrayList<>();
objects.add(new FlamingAsteroid(0, 0, 5, 5));
objects.add(new SpaceStationMir(1, 1, 2, 2));
objects.add(new Meteoroid(10, 10, 15, 15));
objects.add(new SpaceStationIss(12, 12, 14, 14));
List<GameObject> objects = List.of(
new FlamingAsteroid(0, 0, 5, 5),
new SpaceStationMir(1, 1, 2, 2),
new Meteoroid(10, 10, 15, 15),
new SpaceStationIss(12, 12, 14, 14));
objects.stream().forEach(o -> LOGGER.info(o.toString()));
LOGGER.info("");

Expand Down
8 changes: 4 additions & 4 deletions facade/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ public class DwarvenGoldmineFacade {
private final List<DwarvenMineWorker> workers;

public DwarvenGoldmineFacade() {
workers = new ArrayList<>();
workers.add(new DwarvenGoldDigger());
workers.add(new DwarvenCartOperator());
workers.add(new DwarvenTunnelDigger());
workers = List.of(
new DwarvenGoldDigger(),
new DwarvenCartOperator(),
new DwarvenTunnelDigger());
}

public void startNewDay() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

package com.iluwatar.facade;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

Expand All @@ -43,10 +42,10 @@ public class DwarvenGoldmineFacade {
* Constructor
*/
public DwarvenGoldmineFacade() {
workers = new ArrayList<>();
workers.add(new DwarvenGoldDigger());
workers.add(new DwarvenCartOperator());
workers.add(new DwarvenTunnelDigger());
workers = List.of(
new DwarvenGoldDigger(),
new DwarvenCartOperator(),
new DwarvenTunnelDigger());
}

public void startNewDay() {
Expand Down
40 changes: 17 additions & 23 deletions flyweight/src/main/java/com/iluwatar/flyweight/AlchemistShop.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

Expand All @@ -46,29 +45,24 @@ public class AlchemistShop {
* Constructor
*/
public AlchemistShop() {
topShelf = new ArrayList<>();
bottomShelf = new ArrayList<>();
fillShelves();
}

private void fillShelves() {

PotionFactory factory = new PotionFactory();

topShelf.add(factory.createPotion(PotionType.INVISIBILITY));
topShelf.add(factory.createPotion(PotionType.INVISIBILITY));
topShelf.add(factory.createPotion(PotionType.STRENGTH));
topShelf.add(factory.createPotion(PotionType.HEALING));
topShelf.add(factory.createPotion(PotionType.INVISIBILITY));
topShelf.add(factory.createPotion(PotionType.STRENGTH));
topShelf.add(factory.createPotion(PotionType.HEALING));
topShelf.add(factory.createPotion(PotionType.HEALING));

bottomShelf.add(factory.createPotion(PotionType.POISON));
bottomShelf.add(factory.createPotion(PotionType.POISON));
bottomShelf.add(factory.createPotion(PotionType.POISON));
bottomShelf.add(factory.createPotion(PotionType.HOLY_WATER));
bottomShelf.add(factory.createPotion(PotionType.HOLY_WATER));
topShelf = List.of(
factory.createPotion(PotionType.INVISIBILITY),
factory.createPotion(PotionType.INVISIBILITY),
factory.createPotion(PotionType.STRENGTH),
factory.createPotion(PotionType.HEALING),
factory.createPotion(PotionType.INVISIBILITY),
factory.createPotion(PotionType.STRENGTH),
factory.createPotion(PotionType.HEALING),
factory.createPotion(PotionType.HEALING)
);
bottomShelf = List.of(
factory.createPotion(PotionType.POISON),
factory.createPotion(PotionType.POISON),
factory.createPotion(PotionType.POISON),
factory.createPotion(PotionType.HOLY_WATER),
factory.createPotion(PotionType.HOLY_WATER)
);
}

/**
Expand Down

0 comments on commit 6bb3438

Please sign in to comment.