SHARE
TWEET

Untitled

a guest Oct 20th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Bruch {
  2.  
  3.     /* attributes */
  4.     int zaehler;
  5.     int nenner;
  6.    
  7.     /* constructor */
  8.    
  9.     Bruch (int z, int n) {
  10.         zaehler = z;
  11.         nenner = n;
  12.     }
  13.    
  14.     /* Addition */
  15.    
  16.     void add(Bruch r) {
  17.         zaehler = zaehler*r.nenner + r.zaehler*nenner;
  18.         nenner  = nenner*r.nenner;
  19.     }
  20.    
  21.     public String toString() {
  22.         return "(" + zaehler + "/" + nenner + ")";
  23.     }
  24.    
  25. }
RAW Paste Data
Top