Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package h;
- import java.util.*;
- public class App {
- public static void main(String[] args) {
- Scanner sc=new Scanner(System.in);
- House h=new House("Jo","Sofia",22,456);
- House h1=new House("Bobo","Sofia",34,765);
- Apartment ap=new Apartment("Koko","Plovdiv",55,800);
- Apartment ap1=new Apartment("Ivan","Razgrad",80,1000);
- ArrayList<GetPrice> list=new ArrayList<>(Arrays.asList(h,h1,ap,ap1));
- GetPrice result=getMaxPrice(list);
- result.print();
- }
- private static GetPrice getMaxPrice(ArrayList<GetPrice> list) {
- double maxPrice=list.get(0).getPrice();
- int index=0;
- for(int i=0;i<list.size();i++) {
- if(maxPrice<list.get(i).getPrice()) {
- index=i;
- }
- }
- return list.get(index);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement