Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Eslabon {
- private int numeroActual;
- private double longitudActual;
- /**
- * pre: numero y longitud tienen que ser positivos y diferentes de 0.
- * post: inicializa el Eslabón con el numero y la longitud indicados.
- */
- public Eslabon (int numero, double longitud){
- if (numero <= 0 || longitud <= 0.0){
- Error numeroOLongitudInexistentes = new Error("No existe numero y/o longitud negativa o nula");
- throw numeroOLongitudInexistentes;
- } else {
- numeroActual = numero;
- longitudActual = longitud;
- }
- }
- /**
- * post: Devuelve el número de Eslabón.
- */
- public int obtenerNumero(){
- return numeroActual;
- }
- /**
- * post: devuelve la longitud del eslabón.
- */
- public double obtenerLongitud(){
- return longitudActual;
- }
- /**
- * pre: La Longitud no puede ser nula o negativa.
- * post: Cambia la longitud actual del Eslabon.
- */
- public void CambiarLongitud(double nuevaLongitud) {
- if (nuevaLongitud <=0){
- Error longitudInexistente = new Error("No existe longitud negativa o nula");
- throw longitudInexistente;
- } else {
- longitudActual = nuevaLongitud;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement