2023-04-13 16:07:52 +03:00
|
|
|
package lab4;
|
|
|
|
|
|
2023-05-11 16:10:42 +03:00
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
2023-04-13 16:07:52 +03:00
|
|
|
public class Main {
|
|
|
|
|
public static void main(String[] args) {
|
2023-05-25 15:06:01 +03:00
|
|
|
System.out.println(Integer.MIN_VALUE - 1);
|
2023-05-18 16:03:31 +03:00
|
|
|
// todo Comparable
|
2023-04-13 16:07:52 +03:00
|
|
|
//todo equals+hashcode
|
2023-05-11 16:10:42 +03:00
|
|
|
// todo JavaDoc
|
2023-05-25 15:06:01 +03:00
|
|
|
final Furniture/*<Furniture>*/ furniture1 = new Furniture("A", 1, 1, 1, 1);
|
|
|
|
|
final Furniture/*<String>*/ furniture2 = new Furniture("F", 1, 1, 1, 4);
|
|
|
|
|
|
|
|
|
|
System.out.println(furniture1.compareTo(furniture2));
|
|
|
|
|
System.out.println(furniture1.compareTo("furniture2"));
|
|
|
|
|
|
2023-05-11 16:10:42 +03:00
|
|
|
Furniture[] furnitureArray = {
|
2023-05-18 16:03:31 +03:00
|
|
|
furniture1,
|
|
|
|
|
furniture2,
|
|
|
|
|
new Furniture("B", 1, 2, 1, 1),
|
|
|
|
|
new Furniture("C", 1, 1, 3, 1),
|
2023-05-11 16:10:42 +03:00
|
|
|
};
|
|
|
|
|
|
2023-05-18 16:03:31 +03:00
|
|
|
for (Furniture furniture : furnitureArray) {
|
|
|
|
|
// System.out.println(furniture.getMaterial() + " " + furniture.getPrice());
|
|
|
|
|
System.out.println(furniture);
|
|
|
|
|
}
|
|
|
|
|
System.out.println("+++++++++++++");
|
|
|
|
|
|
2023-05-25 15:06:01 +03:00
|
|
|
// furniture1.setAdditional(new Furniture("Y", 1, 1, 1, 0));
|
|
|
|
|
// furniture2.setAdditional("new Furniture(\"Y\", 1, 1, 1, 0)");
|
2023-05-18 16:03:31 +03:00
|
|
|
|
|
|
|
|
// furnitureArray[0].setMaterial("E");
|
|
|
|
|
|
2023-05-11 16:10:42 +03:00
|
|
|
Arrays.sort(furnitureArray, (o1, o2) -> o1.getMaterial().compareTo(o2.getMaterial()));
|
2023-05-18 16:03:31 +03:00
|
|
|
for (Furniture furniture : furnitureArray) {
|
|
|
|
|
System.out.println(furniture);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println("+++++++++++++");
|
2023-05-11 16:10:42 +03:00
|
|
|
|
|
|
|
|
// todo check
|
|
|
|
|
Arrays.sort(furnitureArray, (o1, o2) -> Integer.compare(o2.getPrice(), o1.getPrice()));
|
2023-05-18 16:03:31 +03:00
|
|
|
for (Furniture furniture : furnitureArray) {
|
|
|
|
|
System.out.println(furniture);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
System.out.println("+++++++++++++");
|
2023-04-13 16:07:52 +03:00
|
|
|
}
|
|
|
|
|
}
|