Advertisement
Guest User

isIncludedIn

a guest
Dec 6th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. public boolean isIncludedIn(AbstractImage img2)
  2. {
  3. Iterator<NodeState> itThis = this.iterator();
  4. Iterator<NodeState> it2 = img2.iterator();
  5. if (it2.isEmpty()) {
  6. System.out.println("Image2 est vide!");
  7. return false;
  8. } else {
  9. return isIncludedR(itThis, it2);
  10. }
  11. }
  12.  
  13. private boolean isIncludedR(Iterator<NodeState> itThis, Iterator<NodeState> it2) {
  14. boolean res = true;
  15.  
  16. if (!it2.isEmpty()) {
  17. if (!itThis.isEmpty()) {
  18. if (it2.getValue().equals(NodeState.valueOf(1)) || itThis.getValue().equals(NodeState.valueOf(0))) {
  19. } else if (it2.getValue().equals(NodeState.valueOf(0)) || itThis.getValue().equals(NodeState.valueOf(1))) {
  20. res = false;
  21. } else {
  22. itThis.goLeft();
  23. it2.goLeft();
  24. if (isIncludedR(itThis, it2)) {
  25. itThis.goUp();
  26. it2.goUp();
  27. itThis.goRight();
  28. it2.goRight();
  29. if (!isIncludedR(itThis, it2)) {
  30. res = false;
  31. }
  32. } else {
  33. res = false;
  34. }
  35. itThis.goUp();
  36. it2.goUp();
  37. }
  38. }
  39. }
  40. return res;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement