Create Airplane.java
This commit is contained in:
		
							parent
							
								
									33f8aa39e1
								
							
						
					
					
						commit
						71b6763c9d
					
				
							
								
								
									
										59
									
								
								src/_12_Закревський_Данило_Сергійович/lab4/Airplane.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								src/_12_Закревський_Данило_Сергійович/lab4/Airplane.java
									
									
									
									
									
										Normal file
									
								
							@ -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<Airplane> {
 | 
			
		||||
    
 | 
			
		||||
    public int compare(Airplane a, Airplane b) {
 | 
			
		||||
        return a.getPrice() - b.getPrice();
 | 
			
		||||
    }
 | 
			
		||||
} 
 | 
			
		||||
 | 
			
		||||
class SortByYear implements Comparator<Airplane> {
 | 
			
		||||
 | 
			
		||||
    public int compare(Airplane a, Airplane b) {
 | 
			
		||||
        return a.getYear() - b.getYear();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user