Advertisement
incomplete

FractionCounter

Apr 15th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. public class FractionCounter {
  2.  
  3.     Fraction fraction = new Fraction();
  4.     private int count = 1;
  5.  
  6.  
  7.     FractionCounter(Fraction theFraction){
  8.         fraction = theFraction;
  9.  
  10.     }
  11.  
  12.     public boolean compareAndIncrement(Fraction newFraction){
  13.         if(fraction.equals(newFraction)){
  14.             count++;
  15.             return true;
  16.         }else{
  17.             return false;
  18.         }
  19.     }
  20.  
  21.     public String toString(){
  22.         return this.fraction.getNumerator() + "/" + this.fraction.getDenominator() + " has a count of " + count;
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement