mirror of
				https://github.com/ASDjonok/OOP_IO-2x_2023.git
				synced 2025-11-04 00:29:24 +02:00 
			
		
		
		
	Add files via upload
This commit is contained in:
		
							parent
							
								
									75217080cc
								
							
						
					
					
						commit
						154398a013
					
				
							
								
								
									
										11
									
								
								lab7/lab7.iml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								lab7/lab7.iml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<module type="JAVA_MODULE" version="4">
 | 
				
			||||||
 | 
					  <component name="NewModuleRootManager" inherit-compiler-output="true">
 | 
				
			||||||
 | 
					    <exclude-output />
 | 
				
			||||||
 | 
					    <content url="file://$MODULE_DIR$">
 | 
				
			||||||
 | 
					      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
 | 
				
			||||||
 | 
					    </content>
 | 
				
			||||||
 | 
					    <orderEntry type="inheritedJdk" />
 | 
				
			||||||
 | 
					    <orderEntry type="sourceFolder" forTests="false" />
 | 
				
			||||||
 | 
					  </component>
 | 
				
			||||||
 | 
					</module>
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								lab7/out/production/lab7/lab7/Car.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lab7/out/production/lab7/lab7/Car.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lab7/out/production/lab7/lab7/CarCollection.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lab7/out/production/lab7/lab7/CarCollection.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lab7/out/production/lab7/lab7/CombatsCar.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lab7/out/production/lab7/lab7/CombatsCar.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lab7/out/production/lab7/lab7/ElectricCar.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lab7/out/production/lab7/lab7/ElectricCar.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lab7/out/production/lab7/lab7/Main.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lab7/out/production/lab7/lab7/Main.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lab7/out/production/lab7/lab7/SportsCar.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lab7/out/production/lab7/lab7/SportsCar.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										42
									
								
								lab7/src/lab7/Car.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								lab7/src/lab7/Car.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,42 @@
 | 
				
			|||||||
 | 
					package lab7;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class Car {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected String mark;
 | 
				
			||||||
 | 
					    protected String model;
 | 
				
			||||||
 | 
					    protected int price;
 | 
				
			||||||
 | 
					    protected int year;
 | 
				
			||||||
 | 
					    protected float fuel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Car(String mark, String model, int price, int year, float fuel) {
 | 
				
			||||||
 | 
					        setValues(mark, model, price, year, fuel);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//    Цей конструктор був створений окремо для класу ElectricCar
 | 
				
			||||||
 | 
					    public Car(String mark, String model, int price, int year) {
 | 
				
			||||||
 | 
					        setValues(mark, model, price, year);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setValues(String mark, String model, int price, int year, float fuel) {
 | 
				
			||||||
 | 
					        this.mark = mark;
 | 
				
			||||||
 | 
					        this.model = model;
 | 
				
			||||||
 | 
					        this.price = price;
 | 
				
			||||||
 | 
					        this.year = year;
 | 
				
			||||||
 | 
					        this.fuel = fuel;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setValues(String mark, String model, int price, int year) {
 | 
				
			||||||
 | 
					        this.mark = mark;
 | 
				
			||||||
 | 
					        this.model = model;
 | 
				
			||||||
 | 
					        this.price = price;
 | 
				
			||||||
 | 
					        this.year = year;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void printValues() {
 | 
				
			||||||
 | 
					        System.out.println("Марка: " + mark);
 | 
				
			||||||
 | 
					        System.out.println("Модель: " + model + " " + year);
 | 
				
			||||||
 | 
					        System.out.println("Ціна: " + price + "$");
 | 
				
			||||||
 | 
					        System.out.println("Витрати палива: " + fuel + "л/100км");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										137
									
								
								lab7/src/lab7/CarCollection.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								lab7/src/lab7/CarCollection.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,137 @@
 | 
				
			|||||||
 | 
					package lab7;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class CarCollection<T extends Car> implements List<T> {
 | 
				
			||||||
 | 
					    private final LinkedList<T> carList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public CarCollection() {
 | 
				
			||||||
 | 
					        carList = new LinkedList<>();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public CarCollection(T car) {
 | 
				
			||||||
 | 
					        carList = new LinkedList<>();
 | 
				
			||||||
 | 
					        carList.add(car);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public CarCollection(Collection<? extends T> c) {
 | 
				
			||||||
 | 
					        carList = new LinkedList<>(c);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    //  Реалізація методів List
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int size() {
 | 
				
			||||||
 | 
					        return carList.size();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean isEmpty() {
 | 
				
			||||||
 | 
					        return carList.isEmpty();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean contains(Object o) {
 | 
				
			||||||
 | 
					        return carList.contains(o);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public Iterator<T> iterator() {
 | 
				
			||||||
 | 
					        return carList.iterator();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public Object[] toArray() {
 | 
				
			||||||
 | 
					        return carList.toArray();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public <T1> T1[] toArray(T1[] a) {
 | 
				
			||||||
 | 
					        return carList.toArray(a);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean add(T t) {
 | 
				
			||||||
 | 
					        return carList.add(t);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean remove(Object o) {
 | 
				
			||||||
 | 
					        return carList.remove(o);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean containsAll(Collection<?> c) {
 | 
				
			||||||
 | 
					        return carList.containsAll(c);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean addAll(Collection<? extends T> c) {
 | 
				
			||||||
 | 
					        return carList.addAll(c);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean addAll(int index, Collection<? extends T> c) {
 | 
				
			||||||
 | 
					        return carList.addAll(index, c);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean removeAll(Collection<?> c) {
 | 
				
			||||||
 | 
					        return carList.removeAll(c);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean retainAll(Collection<?> c) {
 | 
				
			||||||
 | 
					        return carList.retainAll(c);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void clear() {
 | 
				
			||||||
 | 
					        carList.clear();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public T get(int index) {
 | 
				
			||||||
 | 
					        return carList.get(index);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public T set(int index, T element) {
 | 
				
			||||||
 | 
					        return carList.set(index, element);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void add(int index, T element) {
 | 
				
			||||||
 | 
					        carList.add(index, element);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public T remove(int index) {
 | 
				
			||||||
 | 
					        return carList.remove(index);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int indexOf(Object o) {
 | 
				
			||||||
 | 
					        return carList.indexOf(o);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int lastIndexOf(Object o) {
 | 
				
			||||||
 | 
					        return carList.lastIndexOf(o);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ListIterator<T> listIterator() {
 | 
				
			||||||
 | 
					        return carList.listIterator();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ListIterator<T> listIterator(int index) {
 | 
				
			||||||
 | 
					        return carList.listIterator(index);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public List<T> subList(int fromIndex, int toIndex) {
 | 
				
			||||||
 | 
					        return carList.subList(fromIndex, toIndex);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										29
									
								
								lab7/src/lab7/CombatsCar.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								lab7/src/lab7/CombatsCar.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					package lab7;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class CombatsCar extends Car {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final int crew;
 | 
				
			||||||
 | 
					    private final float weight;
 | 
				
			||||||
 | 
					    private final String country;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public CombatsCar(String mark, String model, int price, int year, float fuel, int crew, float weight, String country) {
 | 
				
			||||||
 | 
					        super(mark, model, price, year, fuel);
 | 
				
			||||||
 | 
					        this.crew = crew;
 | 
				
			||||||
 | 
					        this.weight = weight;
 | 
				
			||||||
 | 
					        this.country = country;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public String getCountry() {
 | 
				
			||||||
 | 
					        return country;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void printValues() {
 | 
				
			||||||
 | 
					        super.printValues();
 | 
				
			||||||
 | 
					        System.out.println("--- Особливості бойової машини ---");
 | 
				
			||||||
 | 
					        System.out.println("Екіпаж: " + crew + " людей");
 | 
				
			||||||
 | 
					        System.out.println("Бойова маса: " + weight + "т");
 | 
				
			||||||
 | 
					        System.out.println("Країна-виробник: " + country);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										25
									
								
								lab7/src/lab7/ElectricCar.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								lab7/src/lab7/ElectricCar.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					package lab7;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class ElectricCar extends Car {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final float electricity;
 | 
				
			||||||
 | 
					    private final float chargingSpeed;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ElectricCar(String mark, String model, int price, int year, float electricity, int chargingSpeed) {
 | 
				
			||||||
 | 
					        super(mark, model, price, year);
 | 
				
			||||||
 | 
					        this.electricity = electricity;
 | 
				
			||||||
 | 
					        this.chargingSpeed = chargingSpeed;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public float getElectricity() {
 | 
				
			||||||
 | 
					        return electricity;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void printValues() {
 | 
				
			||||||
 | 
					        super.printValues();
 | 
				
			||||||
 | 
					        System.out.println("-Особливості електрокару-");
 | 
				
			||||||
 | 
					        System.out.println("Споживання електроенергії: " + electricity + " кВт·год/100км");
 | 
				
			||||||
 | 
					        System.out.println("Швидкість зарядки (з 0% до 100%): " + chargingSpeed + " хв");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										73
									
								
								lab7/src/lab7/Main.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								lab7/src/lab7/Main.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,73 @@
 | 
				
			|||||||
 | 
					package lab7;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.Comparator;
 | 
				
			||||||
 | 
					import java.util.Scanner;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class Main {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public static void main(String[] args) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//        Використання пустого конструктора CarCollection
 | 
				
			||||||
 | 
					        CarCollection<SportsCar> sportsCars = new CarCollection<>();
 | 
				
			||||||
 | 
					        sportsCars.add(new SportsCar("Ferrari", "458 Italia", 230000, 2015, 9.8f, 562, 202, 4.5f));
 | 
				
			||||||
 | 
					        sportsCars.add(new SportsCar("Lamborghini", "Huracan", 260000, 2020, 9.5f, 640, 211, 5.2f));
 | 
				
			||||||
 | 
					        sportsCars.add(new SportsCar("Porsche", "911", 150000, 2018, 14.3f, 450, 191, 3.0f));
 | 
				
			||||||
 | 
					        sportsCars.add(new SportsCar("McLaren", "570S", 200000, 2017, 11.2f, 562, 204, 3.8f));
 | 
				
			||||||
 | 
					        sportsCars.add(new SportsCar("Aston Martin", "Vantage", 150000, 2021, 12.3f, 503, 195, 4.0f));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//        Сортування спорткарів за ціною
 | 
				
			||||||
 | 
					        System.out.println("~~~~~ Відсортовані спорткари за ціною ~~~~~");
 | 
				
			||||||
 | 
					        sportsCars.sort(Comparator.comparingInt(SportsCar::getPrice));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (int i = sportsCars.size() - 1; i >= 0; i--) {
 | 
				
			||||||
 | 
					            sportsCars.get(i).printValues();
 | 
				
			||||||
 | 
					            System.out.println();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//        Використання конструктора CarCollection з передаванням в його лише один об'єкт
 | 
				
			||||||
 | 
					        CarCollection<CombatsCar> combatsCars = new CarCollection<>(new CombatsCar("Humvee", "M1114", 220000, 1995, 6.5f, 4, 5.5f, "США"));
 | 
				
			||||||
 | 
					        combatsCars.add(new CombatsCar("Puma", "IFV", 3500000, 2010, 10.7f, 6, 31f, "Німеччина"));
 | 
				
			||||||
 | 
					        combatsCars.add(new CombatsCar("Warrior", "IFV", 4500000, 1988, 12.4f, 3, 29f, "Великобританія"));
 | 
				
			||||||
 | 
					        combatsCars.add(new CombatsCar("ZBD", "05", 1200000, 2011, 9.4f, 4, 25f, "Китай"));
 | 
				
			||||||
 | 
					        combatsCars.add(new CombatsCar("VBCI", "IFV", 5000000, 2008, 10.7f, 8, 32f, "Франція"));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//        Пошук бойової машини за країною-виробником
 | 
				
			||||||
 | 
					        Scanner scanner = new Scanner(System.in);
 | 
				
			||||||
 | 
					        System.out.print("Введіть країну-виробницю бойової машини: ");
 | 
				
			||||||
 | 
					        String userCountry = scanner.nextLine();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        System.out.println("Результати пошуку:\n");
 | 
				
			||||||
 | 
					        for (CombatsCar car : combatsCars) {
 | 
				
			||||||
 | 
					            if (car.getCountry().equals(userCountry)) {
 | 
				
			||||||
 | 
					                car.printValues();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ArrayList<ElectricCar> electricCarsList = new ArrayList<>();
 | 
				
			||||||
 | 
					        electricCarsList.add(new ElectricCar("Tesla", "Model S", 80000, 2022, 21.5f, 45));
 | 
				
			||||||
 | 
					        electricCarsList.add(new ElectricCar("Chevrolet", "Bolt", 35000, 2021, 28.0f, 60));
 | 
				
			||||||
 | 
					        electricCarsList.add(new ElectricCar("Nissan", "Leaf", 32000, 2021, 24.0f, 40));
 | 
				
			||||||
 | 
					        electricCarsList.add(new ElectricCar("BMW", "i3", 45000, 2021, 19.5f, 30));
 | 
				
			||||||
 | 
					        electricCarsList.add(new ElectricCar("Hyundai", "Kona", 42000, 2022, 22.0f, 50));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//        Використання конструктора CarCollection з передаванням в його колекцію об'єктів
 | 
				
			||||||
 | 
					        CarCollection<ElectricCar> electricCars = new CarCollection<>(electricCarsList);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//        Пошук автомобіля по діапазону споживання електроенергії
 | 
				
			||||||
 | 
					        System.out.println("\nВведіть діапазон споживання електроенергії (кВт·год/100км):");
 | 
				
			||||||
 | 
					        System.out.print("від ");
 | 
				
			||||||
 | 
					        float electricityLowerLimit = scanner.nextFloat();
 | 
				
			||||||
 | 
					        System.out.print("до ");
 | 
				
			||||||
 | 
					        float electricityUpperLimit = scanner.nextFloat();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        System.out.println("Результати пошуку:\n");
 | 
				
			||||||
 | 
					        for (ElectricCar car : electricCars) {
 | 
				
			||||||
 | 
					            if (car.getElectricity() < electricityUpperLimit & car.getElectricity() > electricityLowerLimit) {
 | 
				
			||||||
 | 
					                car.printValues();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										28
									
								
								lab7/src/lab7/SportsCar.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								lab7/src/lab7/SportsCar.java
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					package lab7;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SportsCar extends Car {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final int power;
 | 
				
			||||||
 | 
					    private final float speed;
 | 
				
			||||||
 | 
					    private final float engineCapacity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public SportsCar(String mark, String model, int price, int year, float fuel, int power, float speed, float engineCapacity) {
 | 
				
			||||||
 | 
					        super(mark, model, price, year, fuel);
 | 
				
			||||||
 | 
					        this.power = power;
 | 
				
			||||||
 | 
					        this.speed = speed;
 | 
				
			||||||
 | 
					        this.engineCapacity = engineCapacity;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public int getPrice() {
 | 
				
			||||||
 | 
					        return price;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void printValues() {
 | 
				
			||||||
 | 
					        super.printValues();
 | 
				
			||||||
 | 
					        System.out.println("-Особливості спорткару-");
 | 
				
			||||||
 | 
					        System.out.println("Потужість: " + power + " кінських сил");
 | 
				
			||||||
 | 
					        System.out.println("Максимальна швидкість: " + speed + " км/год");
 | 
				
			||||||
 | 
					        System.out.println("Об'єм двигуна: " + engineCapacity + "л");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user