Advertisement
Guest User

FizzBuzzUtilities

a guest
Nov 21st, 2012
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.17 KB | None | 0 0
  1. package com.myimportantcompany.fizzbuzz;
  2.  
  3. /**
  4.  * This is the FizzBuzzUtilities class, providing the necessary tools for
  5.  * checking whether numbers are divisible by certain other numbers.
  6.  *
  7.  * @author Simon
  8.  */
  9. public class FizzBuzzUtilities {
  10.     /**
  11.      * This is the number to check with our utilities
  12.      */
  13.     private int numberToCheckWithUtilities;
  14.     public FizzBuzzUtilities(int numberToCheckWithUtilities) {
  15.         this.numberToCheckWithUtilities = numberToCheckWithUtilities;
  16.     }
  17.    
  18.     /**
  19.      * This function checks whether our number is divisible by 3 without a
  20.      * remainder
  21.      *
  22.      * @return True if the number is divisible by 3 without a remainder, false
  23.      *         otherwise
  24.      */
  25.     public boolean isNumberDivisibleByThreeWithoutRemainder() {
  26.         if (((this.numberToCheckWithUtilities / 3) * 3) == this.numberToCheckWithUtilities) {
  27.             return true;
  28.         } else {
  29.             return false;
  30.         }
  31.     }
  32.    
  33.     /**
  34.      * This function checks whether our number is divisible by 5 without a
  35.      * remainder
  36.      *
  37.      * @return True if the number is divisible by 5 without a remainder, false
  38.      *         otherwise
  39.      */
  40.     public boolean isNumberDivisibleByFiveWithoutRemainder() {
  41.         if (((this.numberToCheckWithUtilities / 5) * 5) == this.numberToCheckWithUtilities) {
  42.             return true;
  43.         } else {
  44.             return false;
  45.         }
  46.     }
  47.  
  48.     /**
  49.      * This function checks whether our number is divisible by 5 and
  50.      * 3without a remainder
  51.      * @return True if the number is divisible by 5 and 3 without a remainder,
  52.      *         false otherwise
  53.      */
  54.     public boolean isNumberDivisibleByFiveAndThreeWithoutRemainder() {
  55.         boolean checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
  56.         if (((this.numberToCheckWithUtilities / 3) * 3) == this.numberToCheckWithUtilities) {
  57.             checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = true;
  58.         } else {
  59.             checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
  60.         }
  61.  
  62.         if (((this.numberToCheckWithUtilities / 5) * 5) == this.numberToCheckWithUtilities) {
  63.             checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = true;
  64.         } else {
  65.             checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
  66.         }
  67.         return checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder;
  68.     }
  69.  
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement