Skip to content

Instantly share code, notes, and snippets.

@oscarcs
Created May 16, 2017 04:23
Show Gist options
  • Save oscarcs/00a401f9d2f0af7380ad35b4e37ce7ff to your computer and use it in GitHub Desktop.
Save oscarcs/00a401f9d2f0af7380ad35b4e37ce7ff to your computer and use it in GitHub Desktop.
/**
* Attempts to add a Shape to a NestingShape object. If successful, a
* two-way link is established between the NestingShape and the newly-added
* Shape. Note that this method has package visibility.
* @param shape the shape to be added.
* @throws IllegalArgumentException if an attempt is made to add a Shape
* that will not fit within the bounds of the proposed NestingShape object.
*/
void add(Shape shape) throws IllegalArgumentException {
}
/**
* Removes a particular Shape from a NestingShape instance. Once removed,
* the two-way link between the NestingShape and its former child is
* destroyed. This method has no effect if the Shape specified to remove
* is not a child of the NestingShape. Note that this method has package
* visibility.
* @param shape the shape to be removed.
*/
void remove(Shape shape) {
}
/**
* Returns the Shape at a specified position within a NestingShape. If
* the position specified is less than zero or greater than the number of
* children stored in the NestingShape less one this method thows an
* IndexOutOfBoundsException.
* @param index the specified index position.
*/
public Shape shapeAt(int index) throws IndexOutOfBoundsException {
}
/**
* Returns the number of children contained within a NestingShape object.
* Note this method is not recursive -- it simply returns the number of
* children at the top level within the callee NestingShape object.
*/
public int shapeCount() {
}
/**
* Returns the index of a specified child within a NestingShape object.
* If the Shape specified is not actually a child of the NestingShape
* this method returns -1; otherwise the value returned is in the range
* 0 .. shapeCount() - 1.
* @param shape the shape whose index position within the NestingShape is
* requested.
*/
public int indexOf(Shape shape) {
}
/**
* Returns true if the Shape argument is a child of the NestingShape
* object on which this method is called, false otherwise.
*/
public boolean contains(Shape shape) {
}
/**
* Returns the NestingShape that contains the Shape that method parent
* is called on. If the callee object is not a child within a
* NestingShape instance this method returns null.
*/
public NestingShape parent() {
}
/**
* Returns an ordered list of Shape objects. The first item within
* the list is the root NestingShape of the containment hierarchy.
* The last item within the list is the callee object (hence this
* method always returns a list with at least one item). Any
* intermediate items are NestingShapes that connect the root
* NestingShape to the callee Shape. E.g., given:
*
* NestingShape root = new NestingShape();
* NestingShape intermediate = new NestingShape();
* Shape oval = new OvalShape();
* root.add(intermediate);
* intermediate.add(oval);
*
* a call to oval.path() yields: [root, intermediate, oval].
*/
public List<Shape> path() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment