Advertisement
vencinachev

Fraction

Nov 30th, 2020
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1.  
  2. public class Fraction {
  3.     private int num;
  4.     private int den;
  5.    
  6.     public int getNum() {
  7.         return this.num;
  8.     }
  9.     public void setNum(int num) {
  10.         this.num = num;
  11.     }
  12.     public int getDen() {
  13.         return this.den;
  14.     }
  15.     public void setDen(int den) {
  16.         this.den = den;
  17.     }
  18.    
  19.     public Fraction(int num, int den) {
  20.         this.setNum(num);
  21.         this.setDen(den);
  22.     }
  23.    
  24.     @Override
  25.     public String toString() {
  26.         return this.getNum() + "/" + this.getDen();
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement