Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package q2;
- import java.util.*;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Comparator;
- public class MyInvoice implements IInvoice {
- class SortTotal implements Comparator<Invoice>{
- @Override
- public int compare(Invoice t, Invoice t1) {
- return Double.compare(t.total, t1.total);
- }
- }
- public Invoice f1(ArrayList<Invoice> a) {
- SortTotal sortT = new SortTotal();
- Collections.sort(a, sortT);
- Invoice min = Collections.min(a, sortT);
- return min;
- }
- @Override
- public void f2(ArrayList<Invoice> a, int tt) {
- for (int i = 0; i<a.size(); i++){
- if (a.get(i).total >= 120){
- a.get(i).total += tt;
- }
- }
- }
- @Override
- public int f3(ArrayList<Invoice> a, int tt) {
- int count = 0;
- Iterator iter = a.iterator();
- while (iter.hasNext()){
- Invoice temp = (Invoice) iter.next();
- if (temp.total <= tt){
- count ++;
- }
- }
- return count;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement