From d7edabbf00572e6a8b45f3aea12c573cb0cf7aaa Mon Sep 17 00:00:00 2001 From: mayfff <84086579+mayfff@users.noreply.github.com> Date: Thu, 23 Feb 2023 15:19:54 +0200 Subject: [PATCH] Create FourthLab.java --- .../lab4/FourthLab.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/_12_Закревський_Данило_Сергійович/lab4/FourthLab.java diff --git a/src/_12_Закревський_Данило_Сергійович/lab4/FourthLab.java b/src/_12_Закревський_Данило_Сергійович/lab4/FourthLab.java new file mode 100644 index 0000000..2fbdac6 --- /dev/null +++ b/src/_12_Закревський_Данило_Сергійович/lab4/FourthLab.java @@ -0,0 +1,32 @@ +import java.util.Arrays; + +public class FourthLab { + + public static void main(String[] args) { + final Airplane plane1 = new Airplane("Boeing 747", "passenger", 180, 4, 1970, "Lightblue", 467, 70); + final Airplane plane2 = new Airplane("Airbus A380", "passenger", 575, 4, 2003, "Orange", 850, 389); + final Airplane plane3 = new Airplane("General Dynamics F-16", "military", 9, 1, 1974, "Grey", 1, 45); + final Airplane plane4 = new Airplane("Boeing C-17 Globemaster III", "cargo", 130, 4, 1995, "Grey", 102, 340); + final Airplane plane5 = new Airplane("An-225 Mriya", "cargo", 285, 6, 1990, "White", 20, 500); + Airplane[] planes = {plane1, plane2, plane3, plane4, plane5}; + + System.out.println("List of planes: "); + for(Airplane plane : planes) { + System.out.println(plane); + } + System.out.println(); + + Arrays.sort(planes, new SortByPrice()); + System.out.println("Sorted by price: "); + for(Airplane plane : planes) { + System.out.println(plane); + } + System.out.println(); + + Arrays.sort(planes, new SortByYear().reversed()); + System.out.println("Sorted by year: "); + for(Airplane plane : planes) { + System.out.println(plane); + } + } +}