diff --git a/src/lab4/Furniture.java b/src/lab4/Furniture.java new file mode 100644 index 0000000..e13f68c --- /dev/null +++ b/src/lab4/Furniture.java @@ -0,0 +1,55 @@ +package lab4; + +/** + * My class Furniture. + */ +public class Furniture { + /** + * + */ + private String material; + private int length; + private int height; + private int width; + private int price; + + /** + * + * @param material + * @param length + * @param height + * @param width + * @param price + */ + public Furniture(String material, int length, int height, int width, int price) { + this.material = material; + this.length = length; + this.height = height; + this.width = width; + this.price = price; + } + + public String getMaterial() { + return material; + } + + public int getLength() { + return length; + } + + public int getHeight() { + return height; + } + + public int getWidth() { + return width; + } + + public int getPrice() { + return price; + } + + /*public Furniture() { + + }*/ +} diff --git a/src/lab4/Main.java b/src/lab4/Main.java index 2e69f00..0b8e164 100644 --- a/src/lab4/Main.java +++ b/src/lab4/Main.java @@ -1,7 +1,22 @@ package lab4; +import java.util.Arrays; + public class Main { public static void main(String[] args) { //todo equals+hashcode +// todo JavaDoc + Furniture[] furnitureArray = { + new Furniture("A", 1, 1, 1, 1), + new Furniture("D", 1, 1, 1, 4), + new Furniture("B", 1, 2, 1, 1), + new Furniture("C", 1, 1, 3, 1), + }; + + Arrays.sort(furnitureArray, (o1, o2) -> o1.getMaterial().compareTo(o2.getMaterial())); +// todo print + +// todo check + Arrays.sort(furnitureArray, (o1, o2) -> Integer.compare(o2.getPrice(), o1.getPrice())); } }