Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int tuple[];
- NaturalNumberTuple nnt;
- public NaturalNumberTuple(int[] numbers) {
- int[] tuple = new int[numbers.length];
- for(int i : numbers){
- tuple[i] = numbers[i];
- }
- // TODO implement constructor
- // throw new UnsupportedOperationException("Constructor not yet implemented");
- }
- /**
- * Inserts the specified {@code number} at the end of this tuple. If {@code number} is smaller or equal to 0, this
- * method has no effect.
- *
- * @param number
- * the number to be inserted
- * @return the tuple resulting from inserting the specified {@code number}. If {@code number} is smaller or equal to
- * 0, this tuple is returned without any modifications.
- */
- public NaturalNumberTuple insert(int number) {
- int placeholderTuple[] = new int[tuple.length+1];
- for(int i : tuple){
- placeholderTuple[i] = tuple[i];
- if(number > 0){
- placeholderTuple[placeholderTuple.length-1] = number;
- }
- }
- return nnt.NaturalNumberTuple(placeholderTuple[]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement