Vla_DOS

Untitled

Mar 20th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.44 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.time.LocalDate;
  4. import java.util.LinkedList;
  5. import java.util.Scanner;
  6.  
  7. public class Main {
  8.  
  9.     static void Input(LinkedList<Car> carList){
  10.             Car carAudi = new Car("Audi", "BK 2000 CE", 2018, false, LocalDate.of(2020,06,12),LocalDate.of(2020,10,12));
  11.             Car carBMW = new Car("BMW", "BK 7000 CE", 2019, true, LocalDate.of(2022,01,12),LocalDate.of(2022,04,12));
  12.             carList.add(carAudi);
  13.             carList.add(carBMW);
  14.     }
  15.     static void GetRentedCarList(LinkedList<Car> carList){
  16.         for (var i:carList) {
  17.             if(i.Rented)
  18.                 System.out.println("\n Марка автомобіля: " + i.Brand + "\n Номерний знак: " + i.LicensePlate + "\n Рік випуску: " + i.YearOfManufacture  + "\n автомобіль орендовано (true/false): " + i.Rented + "\n Дата " +
  19.                         "оренди :" + i.DateLease + "\n Термін оренди: " + i.LeaseTerm);
  20.         }
  21.     }
  22.  
  23.     static void GetNotRentedCarList(LinkedList<Car> carList){
  24.         for (var i:carList) {
  25.             if(!i.Rented)
  26.                 System.out.println("\n Марка автомобіля: " + i.Brand + "\n Номерний знак: " + i.LicensePlate + "\n Рік випуску: " + i.YearOfManufacture  + "\n автомобіль орендовано (true/false): " + i.Rented + "\n Дата " +
  27.                         "оренди :" + i.DateLease + "\n Термін оренди: " + i.LeaseTerm);        }
  28.     }
  29.  
  30.  
  31.     static void GetList(LinkedList<Car> carList){
  32.         for (var i:carList) {
  33.             System.out.println("\n Марка автомобіля: " + i.Brand + "\n Номерний знак: " + i.LicensePlate + "\n Рік випуску: " + i.YearOfManufacture  + "\n автомобіль орендовано (true/false): " + i.Rented + "\n Дата " +
  34.                     "оренди :" + i.DateLease + "\n Термін оренди: " + i.LeaseTerm);        }
  35.     }
  36.  
  37.     static void GetListWhichWillBeVacatedInSpecifiedMonth(LinkedList<Car> carList, int month){
  38.         for (var i:carList) {
  39.             if(i.LeaseTerm.getMonth().getValue() == month)
  40.                 System.out.println("\n Марка автомобіля: " + i.Brand + "\n Номерний знак: " + i.LicensePlate + "\n Рік випуску: " + i.YearOfManufacture  + "\n автомобіль орендовано (true/false): " + i.Rented + "\n Дата " +
  41.                         "оренди :" + i.DateLease + "\n Термін оренди: " + i.LeaseTerm);        }
  42.     }
  43.  
  44.     public static void main(String[] args) {
  45.         Scanner in = new Scanner(System.in);
  46.  
  47.         var carList = new LinkedList<Car>();
  48.  
  49.         Input(carList);
  50.  
  51.         System.out.println("\n Список всіх автомобілів: \n");
  52.         GetList(carList);
  53.  
  54.         System.out.println("\n Список орендованих автомобілів: \n");
  55.         GetRentedCarList(carList);
  56.  
  57.         System.out.println("\n Список вільних автомобілів: \n");
  58.         GetNotRentedCarList(carList);
  59.  
  60.         System.out.println("\n Пошук автомобілів, що звільняться з оренди у вказаному місяці:");
  61.         System.out.print("\n  Введіть місяць: ");
  62.         int month = in.nextInt();
  63.         GetListWhichWillBeVacatedInSpecifiedMonth(carList, month);
  64.     }
  65. }
  66.  
Advertisement
Add Comment
Please, Sign In to add comment