Advertisement
fursty

OOP nikva ideq

Apr 16th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. import java.util.Iterator;
  2. import java.util.List;
  3. import java.util.SortedSet;
  4. import java.util.TreeSet;
  5.  
  6. public class RectangleCollection {
  7. private SortedSet<ColorRectangle>rects = new TreeSet<ColorRectangle>();
  8.  
  9. public ColorRectangle calcUnionColl() {
  10. ColorRectangle r=new ColorRectangle();
  11. for(Iterator<ColorRectangle> it = rects.iterator(); it.hasNext();) {
  12. ColorRectangle current = it.next();
  13. r = r.unionRect(current);
  14. }
  15. return r;}
  16.  
  17. public List<ColorRectangle>reverseList(){
  18. List<ColorRectangle>list1=new ArrayList<ColorRectangle>(rects);
  19. List<ColorRectangle>reversed=new ArrayList<ColorRectangle>();
  20. for(ListIterator<ColorRectangle>it=list1.listIterator(list1.size()); it.hasPrevious();) {
  21. reversed.add(it.previous());}
  22. return reversed;}
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement