Advertisement
Dimitar_Ivanov_16408

interface

Jan 29th, 2020
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement