Add java 11 (#1049)

This commit is contained in:
Leon Mak 2019-10-28 04:08:09 +08:00 committed by Ilkka Seppälä
parent 63fb8dc318
commit 6bb3438965
5 changed files with 31 additions and 43 deletions

View File

@ -128,10 +128,6 @@ public class App {
final Customer customer1 = new Customer(1, "Adam", "Adamson"); final Customer customer1 = new Customer(1, "Adam", "Adamson");
final Customer customer2 = new Customer(2, "Bob", "Bobson"); final Customer customer2 = new Customer(2, "Bob", "Bobson");
final Customer customer3 = new Customer(3, "Carl", "Carlson"); final Customer customer3 = new Customer(3, "Carl", "Carlson");
final List<Customer> customers = new ArrayList<>(); return List.of(customer1, customer2, customer3);
customers.add(customer1);
customers.add(customer2);
customers.add(customer3);
return customers;
} }
} }

View File

@ -26,7 +26,6 @@ package com.iluwatar.doubledispatch;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -59,11 +58,11 @@ public class App {
*/ */
public static void main(String[] args) { public static void main(String[] args) {
// initialize game objects and print their status // initialize game objects and print their status
List<GameObject> objects = new ArrayList<>(); List<GameObject> objects = List.of(
objects.add(new FlamingAsteroid(0, 0, 5, 5)); new FlamingAsteroid(0, 0, 5, 5),
objects.add(new SpaceStationMir(1, 1, 2, 2)); new SpaceStationMir(1, 1, 2, 2),
objects.add(new Meteoroid(10, 10, 15, 15)); new Meteoroid(10, 10, 15, 15),
objects.add(new SpaceStationIss(12, 12, 14, 14)); new SpaceStationIss(12, 12, 14, 14));
objects.stream().forEach(o -> LOGGER.info(o.toString())); objects.stream().forEach(o -> LOGGER.info(o.toString()));
LOGGER.info(""); LOGGER.info("");

View File

@ -146,10 +146,10 @@ public class DwarvenGoldmineFacade {
private final List<DwarvenMineWorker> workers; private final List<DwarvenMineWorker> workers;
public DwarvenGoldmineFacade() { public DwarvenGoldmineFacade() {
workers = new ArrayList<>(); workers = List.of(
workers.add(new DwarvenGoldDigger()); new DwarvenGoldDigger(),
workers.add(new DwarvenCartOperator()); new DwarvenCartOperator(),
workers.add(new DwarvenTunnelDigger()); new DwarvenTunnelDigger());
} }
public void startNewDay() { public void startNewDay() {

View File

@ -23,7 +23,6 @@
package com.iluwatar.facade; package com.iluwatar.facade;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -43,10 +42,10 @@ public class DwarvenGoldmineFacade {
* Constructor * Constructor
*/ */
public DwarvenGoldmineFacade() { public DwarvenGoldmineFacade() {
workers = new ArrayList<>(); workers = List.of(
workers.add(new DwarvenGoldDigger()); new DwarvenGoldDigger(),
workers.add(new DwarvenCartOperator()); new DwarvenCartOperator(),
workers.add(new DwarvenTunnelDigger()); new DwarvenTunnelDigger());
} }
public void startNewDay() { public void startNewDay() {

View File

@ -26,7 +26,6 @@ package com.iluwatar.flyweight;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -46,29 +45,24 @@ public class AlchemistShop {
* Constructor * Constructor
*/ */
public AlchemistShop() { public AlchemistShop() {
topShelf = new ArrayList<>();
bottomShelf = new ArrayList<>();
fillShelves();
}
private void fillShelves() {
PotionFactory factory = new PotionFactory(); PotionFactory factory = new PotionFactory();
topShelf = List.of(
topShelf.add(factory.createPotion(PotionType.INVISIBILITY)); factory.createPotion(PotionType.INVISIBILITY),
topShelf.add(factory.createPotion(PotionType.INVISIBILITY)); factory.createPotion(PotionType.INVISIBILITY),
topShelf.add(factory.createPotion(PotionType.STRENGTH)); factory.createPotion(PotionType.STRENGTH),
topShelf.add(factory.createPotion(PotionType.HEALING)); factory.createPotion(PotionType.HEALING),
topShelf.add(factory.createPotion(PotionType.INVISIBILITY)); factory.createPotion(PotionType.INVISIBILITY),
topShelf.add(factory.createPotion(PotionType.STRENGTH)); factory.createPotion(PotionType.STRENGTH),
topShelf.add(factory.createPotion(PotionType.HEALING)); factory.createPotion(PotionType.HEALING),
topShelf.add(factory.createPotion(PotionType.HEALING)); factory.createPotion(PotionType.HEALING)
);
bottomShelf.add(factory.createPotion(PotionType.POISON)); bottomShelf = List.of(
bottomShelf.add(factory.createPotion(PotionType.POISON)); factory.createPotion(PotionType.POISON),
bottomShelf.add(factory.createPotion(PotionType.POISON)); factory.createPotion(PotionType.POISON),
bottomShelf.add(factory.createPotion(PotionType.HOLY_WATER)); factory.createPotion(PotionType.POISON),
bottomShelf.add(factory.createPotion(PotionType.HOLY_WATER)); factory.createPotion(PotionType.HOLY_WATER),
factory.createPotion(PotionType.HOLY_WATER)
);
} }
/** /**