diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/OOP_IO-2x_2023.iml b/.idea/OOP_IO-2x_2023.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/OOP_IO-2x_2023.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..21f8297 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lab1/lab1.iml b/lab1/lab1.iml new file mode 100644 index 0000000..684c1d6 --- /dev/null +++ b/lab1/lab1.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/lab2/lab2.iml b/lab2/lab2.iml new file mode 100644 index 0000000..d536c2e --- /dev/null +++ b/lab2/lab2.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/lab3/lab3.iml b/lab3/lab3.iml new file mode 100644 index 0000000..48a36c2 --- /dev/null +++ b/lab3/lab3.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/lab4/EducationalInstitution/.idea/.gitignore b/lab4/EducationalInstitution/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/lab4/EducationalInstitution/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/lab4/EducationalInstitution/.idea/misc.xml b/lab4/EducationalInstitution/.idea/misc.xml new file mode 100644 index 0000000..7464918 --- /dev/null +++ b/lab4/EducationalInstitution/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lab4/EducationalInstitution/.idea/modules.xml b/lab4/EducationalInstitution/.idea/modules.xml new file mode 100644 index 0000000..6eb3842 --- /dev/null +++ b/lab4/EducationalInstitution/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lab4/EducationalInstitution/EducationalInstitution.iml b/lab4/EducationalInstitution/EducationalInstitution.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/lab4/EducationalInstitution/EducationalInstitution.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/lab4/EducationalInstitution/out/production/EducationalInstitution/EducationalInstitution.class b/lab4/EducationalInstitution/out/production/EducationalInstitution/EducationalInstitution.class new file mode 100644 index 0000000..629ed24 Binary files /dev/null and b/lab4/EducationalInstitution/out/production/EducationalInstitution/EducationalInstitution.class differ diff --git a/lab4/EducationalInstitution/out/production/EducationalInstitution/Main.class b/lab4/EducationalInstitution/out/production/EducationalInstitution/Main.class new file mode 100644 index 0000000..8979c07 Binary files /dev/null and b/lab4/EducationalInstitution/out/production/EducationalInstitution/Main.class differ diff --git a/lab4/EducationalInstitution/src/Main.java b/lab4/EducationalInstitution/src/Main.java new file mode 100644 index 0000000..e69de29 diff --git a/lab4/untitled/.idea/.gitignore b/lab4/untitled/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/lab4/untitled/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/lab4/untitled/.idea/misc.xml b/lab4/untitled/.idea/misc.xml new file mode 100644 index 0000000..7464918 --- /dev/null +++ b/lab4/untitled/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lab4/untitled/.idea/modules.xml b/lab4/untitled/.idea/modules.xml new file mode 100644 index 0000000..3007dae --- /dev/null +++ b/lab4/untitled/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lab4/untitled/out/production/untitled/Main.class b/lab4/untitled/out/production/untitled/Main.class new file mode 100644 index 0000000..8e640c2 Binary files /dev/null and b/lab4/untitled/out/production/untitled/Main.class differ diff --git a/lab4/untitled/out/production/untitled/SeaShip.class b/lab4/untitled/out/production/untitled/SeaShip.class new file mode 100644 index 0000000..751a909 Binary files /dev/null and b/lab4/untitled/out/production/untitled/SeaShip.class differ diff --git a/lab4/untitled/src/Main.java b/lab4/untitled/src/Main.java new file mode 100644 index 0000000..8ecc5af --- /dev/null +++ b/lab4/untitled/src/Main.java @@ -0,0 +1,56 @@ +import java.util.*; + +public class Main { + public static void main(String[] args) { + List ships = createList(); + + printList(ships); + + ships = sortList(ships); + + System.out.println("=============================="); + + printList(ships); + } + + private static ArrayList createList() { + ArrayList ships = new ArrayList<>(); + Random random = new Random(); + + for (int i = 0; i < 10; i++) + ships.add(new SeaShip("name" + (i + 1), "class" + (i + 1), "type" + (i + 1), + random.nextInt(10000) + 1000, random.nextDouble() * 100 + 20, + random.nextInt(10000) + 1000, random.nextDouble() * 100)); + +// ships.add(new SeaShip("nameA", "classA", "typeA", +// random.nextInt(10000) + 1000, 100d, +// random.nextInt(10000) + 1000, 120d)); +// ships.add(new SeaShip("nameA", "classA", "typeA", +// random.nextInt(10000) + 1000, 100d, +// random.nextInt(10000) + 1000, 130d)); +// ships.add(new SeaShip("nameA", "classA", "typeA", +// random.nextInt(10000) + 1000, 100d, +// random.nextInt(10000) + 1000, 140d)); +// ships.add(new SeaShip("nameA", "classA", "typeA", +// random.nextInt(10000) + 1000, 120d, +// random.nextInt(10000) + 1000, 120d)); +// ships.add(new SeaShip("nameA", "classA", "typeA", +// random.nextInt(10000) + 1000, 120d, +// random.nextInt(10000) + 1000, 100d)); + + return ships; + } + + private static List sortList(List list) { + Comparator comparator = Comparator.comparing(SeaShip::getLength).reversed() + .thenComparing(SeaShip::getMaxSpeed); + + list.sort(comparator); + + return list; + } + + private static void printList(List list) { + list.forEach(System.out::println); + } +} diff --git a/lab4/untitled/src/SeaShip.java b/lab4/untitled/src/SeaShip.java new file mode 100644 index 0000000..8ebf9cd --- /dev/null +++ b/lab4/untitled/src/SeaShip.java @@ -0,0 +1,86 @@ + +public class SeaShip { + private String name; + private String shipClass; + private String type; + private Integer weight; + private Double length; + private Integer power; + private Double maxSpeed; + + public SeaShip(String name, String shipClass, String type, + Integer weight, Double length, Integer power, Double maxSpeed) { + this.name = name; + this.shipClass = shipClass; + this.type = type; + this.weight = weight; + this.length = length; + this.power = power; + this.maxSpeed = maxSpeed; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getShipClass() { + return shipClass; + } + + public void setShipClass(String shipClass) { + this.shipClass = shipClass; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Integer getWeight() { + return weight; + } + + public void setWeight(Integer weight) { + this.weight = weight; + } + + public Double getLength() { + return length; + } + + public void setLength(Double length) { + this.length = length; + } + + public Integer getPower() { + return power; + } + + public void setPower(Integer power) { + this.power = power; + } + + public Double getMaxSpeed() { + return maxSpeed; + } + + public void setMaxSpeed(Double maxSpeed) { + this.maxSpeed = maxSpeed; + } + + @Override + public String toString() { + return "Sea ship '" + name + "', class: " + shipClass + ", type: " + type + ".\n" + + "Weight: " + weight + "\n" + + "Length: " + length + "\n" + + "Engine power: " + power + "\n" + + "Max speed: " + maxSpeed + "\n"; + } +} \ No newline at end of file diff --git a/lab4/untitled/untitled.iml b/lab4/untitled/untitled.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/lab4/untitled/untitled.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file