SHARE
TWEET

interface

Dimitar_Ivanov_16408 Jan 29th, 2020 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.ArrayList;
  2.  
  3. interface Building {
  4.    
  5.  
  6. abstract double getPrice();
  7. abstract String getName();
  8. public static Building maxPrice(ArrayList <Building> buildings) {
  9.     Building  max=buildings.get(0);
  10.     for(int i=0;i<buildings.size();i++) {
  11.         if(max.getPrice()<(buildings.get(i).getPrice())) {//finds the object with highest price
  12.         max=buildings.get(i);
  13.         }
  14.     }
  15.     return max;
  16.    
  17. }
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top