Initial commit for 4.4
parent
b35f991d5d
commit
cb103b8a62
@ -0,0 +1,4 @@
|
|||||||
|
package _4._4;
|
||||||
|
|
||||||
|
public class Chair implements Furniture {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package _4._4;
|
||||||
|
|
||||||
|
public class Desk extends Table {
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package _4._4;
|
||||||
|
|
||||||
|
public interface Furniture {
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package _4._4;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Office extends Room {
|
||||||
|
private List<Desk> desks;
|
||||||
|
private List<Chair> chairs;
|
||||||
|
|
||||||
|
public Office(List<Furniture> furniture, List<Desk> desks, List<Chair> chairs) {
|
||||||
|
super(furniture);
|
||||||
|
if(desks.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("An Office must have at least 1 Desk");
|
||||||
|
}
|
||||||
|
this.desks = desks;
|
||||||
|
if(chairs.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("An Office must have at least 1 Chair");
|
||||||
|
}
|
||||||
|
this.chairs = chairs;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package _4._4;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Room {
|
||||||
|
protected List<Furniture> furniture;
|
||||||
|
|
||||||
|
public Room(List<Furniture> furniture) {
|
||||||
|
this.furniture = furniture;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
package _4._4;
|
||||||
|
|
||||||
|
public class Table implements Furniture {
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package _4._4;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Office office = new Office(
|
||||||
|
Arrays.asList(new Chair()),
|
||||||
|
Arrays.asList(new Desk()),
|
||||||
|
Arrays.asList(new Chair())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue