Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- interface Building {
- abstract double getPrice();
- abstract String getName();
- public static Building maxPrice(ArrayList <Building> buildings) {
- Building max=buildings.get(0);
- for(int i=0;i<buildings.size();i++) {
- if(max.getPrice()<(buildings.get(i).getPrice())) {//finds the object with highest price
- max=buildings.get(i);
- }
- }
- return max;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement