X-Git-Url: https://git.llucax.com/z.facultad/75.62/c2tp1.git/blobdiff_plain/730f65e26702338c2fea2a133c2df73de422c27d..f9ae0eb22d1b5e8b12030d43c77c634c81743e73:/src/Fraccion.java diff --git a/src/Fraccion.java b/src/Fraccion.java index 7cf9d86..8bd3ec4 100644 --- a/src/Fraccion.java +++ b/src/Fraccion.java @@ -1,41 +1,5 @@ -class CeroDenExc extends Exception { - - private int num; - - public int getNum() { - return num; - } - - public void setNum(int n) { - num = n; - } - - public CeroDenExc(int num) { - setNum(num); - } - - public String toString() { - return "Division por 0 (numerador = " + getNum() + ")"; - } - -} - -interface OperFrac { - - public Fraccion mas(Fraccion f); - - public Fraccion menos(Fraccion f); - -} - -interface ComparaFrac { - - public int compareTo(Fraccion f); - -} - -class Fraccion implements OperFrac, ComparaFrac { +public class Fraccion implements OperFrac, ComparaFrac { private int num; private int den; @@ -124,23 +88,6 @@ class Fraccion implements OperFrac, ComparaFrac { setDen(getDen() / d); } - // Test - public static void main(String args[]) throws CeroDenExc { - try { - Fraccion f = new Fraccion(10, 0); - } catch (CeroDenExc e) { - System.out.println("Ahhh! Esta rota la fraccion!" - + " tiene numerador " + e.getNum() + " y divisor 0"); - } - Fraccion f1 = new Fraccion(2, 10); - System.out.println("f1 = " + f1); - System.out.println("f1 + f1 = " + f1.mas(f1)); - Fraccion f3 = f1.menos(new Fraccion(100, 4)); - System.out.println("f3 = " + f3); - System.out.println("f3 comparado a f1 = " + f3.compareTo(f1)); - //System.out.println("Java esta roto en el manejo de excepciones!!!"); - } - } // vim: set et sw=4 sts=4 :