Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.myimportantcompany.fizzbuzz;
- /**
- * This is the FizzBuzzUtilities class, providing the necessary tools for
- * checking whether numbers are divisible by certain other numbers.
- *
- * @author Simon
- */
- public class FizzBuzzUtilities {
- /**
- * This is the number to check with our utilities
- */
- private int numberToCheckWithUtilities;
- public FizzBuzzUtilities(int numberToCheckWithUtilities) {
- this.numberToCheckWithUtilities = numberToCheckWithUtilities;
- }
- /**
- * This function checks whether our number is divisible by 3 without a
- * remainder
- *
- * @return True if the number is divisible by 3 without a remainder, false
- * otherwise
- */
- public boolean isNumberDivisibleByThreeWithoutRemainder() {
- if (((this.numberToCheckWithUtilities / 3) * 3) == this.numberToCheckWithUtilities) {
- return true;
- } else {
- return false;
- }
- }
- /**
- * This function checks whether our number is divisible by 5 without a
- * remainder
- *
- * @return True if the number is divisible by 5 without a remainder, false
- * otherwise
- */
- public boolean isNumberDivisibleByFiveWithoutRemainder() {
- if (((this.numberToCheckWithUtilities / 5) * 5) == this.numberToCheckWithUtilities) {
- return true;
- } else {
- return false;
- }
- }
- /**
- * This function checks whether our number is divisible by 5 and
- * 3without a remainder
- * @return True if the number is divisible by 5 and 3 without a remainder,
- * false otherwise
- */
- public boolean isNumberDivisibleByFiveAndThreeWithoutRemainder() {
- boolean checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
- if (((this.numberToCheckWithUtilities / 3) * 3) == this.numberToCheckWithUtilities) {
- checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = true;
- } else {
- checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
- }
- if (((this.numberToCheckWithUtilities / 5) * 5) == this.numberToCheckWithUtilities) {
- checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = true;
- } else {
- checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder = false;
- }
- return checkVariableForIsNumberDivisibleByFiveAndThreeWithoutRemainder;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement