2015-09-07 11:44:36 -06:00
|
|
|
// typeinfo/SnowRemovalRobot.java
|
2016-12-30 17:23:13 -08:00
|
|
|
// (c)2017 MindView LLC: see Copyright.txt
|
2015-11-15 15:51:35 -08:00
|
|
|
// We make no guarantees that this code is fit for any purpose.
|
2016-09-23 13:23:35 -06:00
|
|
|
// Visit http://OnJava8.com for more book information.
|
2015-06-15 17:47:35 -07:00
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
public class SnowRemovalRobot implements Robot {
|
|
|
|
private String name;
|
2015-12-15 11:47:04 -08:00
|
|
|
public SnowRemovalRobot(String name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
2015-06-15 17:47:35 -07:00
|
|
|
@Override
|
|
|
|
public String name() { return name; }
|
|
|
|
@Override
|
|
|
|
public String model() { return "SnowBot Series 11"; }
|
2015-12-15 11:47:04 -08:00
|
|
|
private List<Operation> ops = Arrays.asList(
|
|
|
|
new Operation(
|
|
|
|
() -> name + " can shovel snow",
|
|
|
|
() -> System.out.println(name + " shoveling snow")),
|
|
|
|
new Operation(
|
|
|
|
() -> name + " can chip ice",
|
|
|
|
() -> System.out.println(name + " chipping ice")),
|
|
|
|
new Operation(
|
|
|
|
() -> name + " can clear the roof",
|
|
|
|
() -> System.out.println(name + " clearing roof")));
|
|
|
|
public List<Operation> operations() { return ops; }
|
2015-06-15 17:47:35 -07:00
|
|
|
public static void main(String[] args) {
|
2015-12-15 11:47:04 -08:00
|
|
|
Robot.test(new SnowRemovalRobot("Slusher"));
|
2015-06-15 17:47:35 -07:00
|
|
|
}
|
2015-09-07 11:44:36 -06:00
|
|
|
}
|
|
|
|
/* Output:
|
2015-06-15 17:47:35 -07:00
|
|
|
Robot name: Slusher
|
|
|
|
Robot model: SnowBot Series 11
|
|
|
|
Slusher can shovel snow
|
|
|
|
Slusher shoveling snow
|
|
|
|
Slusher can chip ice
|
|
|
|
Slusher chipping ice
|
|
|
|
Slusher can clear the roof
|
|
|
|
Slusher clearing roof
|
2015-09-07 11:44:36 -06:00
|
|
|
*/
|