From 71b6763c9d82d57bbc56f978df65890970e45862 Mon Sep 17 00:00:00 2001 From: mayfff <84086579+mayfff@users.noreply.github.com> Date: Thu, 23 Feb 2023 15:18:47 +0200 Subject: [PATCH] Create Airplane.java --- .../lab4/Airplane.java | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/_12_Закревський_Данило_Сергійович/lab4/Airplane.java diff --git a/src/_12_Закревський_Данило_Сергійович/lab4/Airplane.java b/src/_12_Закревський_Данило_Сергійович/lab4/Airplane.java new file mode 100644 index 0000000..b65ace1 --- /dev/null +++ b/src/_12_Закревський_Данило_Сергійович/lab4/Airplane.java @@ -0,0 +1,59 @@ +import java.util.Comparator; + +public class Airplane { + private String name; + private String type; + private int weight; + private int amountOfEngines; + private int year; + private String color; + private int capacity; + private int price; + + + public Airplane(String name, String type, int weight, int amountOfEngines, int year, String color, int capacity, int price) { + this.name = name; + this.type = type; + this.weight = weight; + this.amountOfEngines = amountOfEngines; + this.year = year; + this.color = color; + this.capacity = capacity; + this.price = price; + } + + public int getPrice() { + return price; + } + + public int getYear() { + return year; + } + + @Override + public String toString() { + return "Plane : " + + "name = " + name + + ", type = " + type + + ", weight = " + weight + " tons" + + ", amount of engines = " + amountOfEngines + + ", year = " + year + + ", color = " + color + + ", capacity = " + capacity + + ", price = " + price + " millions dollars."; + } +} + +class SortByPrice implements Comparator { + + public int compare(Airplane a, Airplane b) { + return a.getPrice() - b.getPrice(); + } +} + +class SortByYear implements Comparator { + + public int compare(Airplane a, Airplane b) { + return a.getYear() - b.getYear(); + } +}