





Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!






public class Point { public double x; public double y; public Point(double x, double y) { this.x = x; this.y = y; } public String toString() { return "(" + x + ", " + y + ")"; } }
public class Figure { // atributos private String name; private Node
// método para añadir puntos public void addPoint(Point p, int position) throws FigureException { // apartado 2 } // method to return the info public String toString() { // apartado 3 (puede dividirse en dos métodos) } }
public class Node
public void addPoint(Point p, int position)
String toStringMenorAMayor()
BSTree
public class FigureException extends Exception { public FigureException(String message) { super(message); } } Criterios de corrección: (0, 5 ) Si extiende de Exception, tiene el constructor con un mensaje y llama a super. 0 en caso contrario.
public void addPoint(Point p, int position) throws FigureException { Node
public boolean isEmpty() { return (this.root == null); } public E getInfo() { if (!this.isEmpty()) { return this.root.getInfo(); } return null; } public Comparable
public String toStringInOrder() { String treeStr = ""; if(!this.isEmpty()) { // Izquierda if(!this.getLeft().isEmpty()) { treeStr = treeStr + this.getLeft().toStringInOrder(); } // Raíz treeStr = treeStr + this.getInfo().toString() + "\n"; // Derecha if(!this.getRight().isEmpty()) { treeStr = treeStr + this.getRight().toStringInOrder(); } } return treeStr; } public void insert(Comparable key, E info) { if(this.isEmpty()) {
this.root = new LBSNode