Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. int tuple[];
  2. NaturalNumberTuple nnt;
  3. public NaturalNumberTuple(int[] numbers) {
  4. int[] tuple = new int[numbers.length];
  5. for(int i : numbers){
  6. tuple[i] = numbers[i];
  7. }
  8. // TODO implement constructor
  9. // throw new UnsupportedOperationException("Constructor not yet implemented");
  10. }
  11.  
  12. /**
  13. * Inserts the specified {@code number} at the end of this tuple. If {@code number} is smaller or equal to 0, this
  14. * method has no effect.
  15. *
  16. * @param number
  17. * the number to be inserted
  18. * @return the tuple resulting from inserting the specified {@code number}. If {@code number} is smaller or equal to
  19. * 0, this tuple is returned without any modifications.
  20. */
  21. public NaturalNumberTuple insert(int number) {
  22. int placeholderTuple[] = new int[tuple.length+1];
  23. for(int i : tuple){
  24. placeholderTuple[i] = tuple[i];
  25. if(number > 0){
  26. placeholderTuple[placeholderTuple.length-1] = number;
  27. }
  28. }
  29. return nnt.NaturalNumberTuple(placeholderTuple[]);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement