Advertisement
Samorokimetal

PropertiesBook 22.11.2020

Nov 22nd, 2020 (edited)
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. public class PropertiesBook {
  4.     private ArrayList<Property> properties = new ArrayList<>();
  5.  
  6.     public Property findCheapestProperty() {
  7.         Property cheapestProperty = properties.get(0);
  8.         for (int i = 0; i < properties.size(); i++) {
  9.             if (properties.get(i).getPrice() < cheapestProperty.getPrice()) {
  10.                 cheapestProperty = properties.get(i);
  11.             }
  12.         }
  13.         return cheapestProperty;
  14.     }
  15.  
  16.     public ArrayList getProperties() {
  17.         return properties;
  18.     }
  19.  
  20.     public void addProperty(Property property) {
  21.         this.properties.add(property);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement