From ca6ec18f20d8bd57e7a4621968a7986d29fb8965 Mon Sep 17 00:00:00 2001 From: samr Date: Sat, 15 Oct 2022 10:38:28 -0700 Subject: [PATCH 1/7] Update FizzBuzzTest.java --- src/test/java/FizzBuzzTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/test/java/FizzBuzzTest.java b/src/test/java/FizzBuzzTest.java index 73ab761c..c308e595 100644 --- a/src/test/java/FizzBuzzTest.java +++ b/src/test/java/FizzBuzzTest.java @@ -1,17 +1,32 @@ +// FizzBuzzTest.java +// Tests for FizzBuzz + +// imports org.junit.Assert.assertEquals import static org.junit.Assert.assertEquals; +// imports java.io.BufferedOutputStream import java.io.BufferedOutputStream; +// imports java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream; +// imports java.io.IOException import java.io.IOException; +// imports java.io.PrintStream import java.io.PrintStream; +// imports org.junit.After import org.junit.After; +// imports org.junit.Before import org.junit.Before; +// imports org.junit.Test import org.junit.Test; +// imports org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContext; +// imports org.springframework.context.ConfigurableApplicationContext import org.springframework.context.ConfigurableApplicationContext; +// imports org.springframework.context.support.ClassPathXmlApplicationContext import org.springframework.context.support.ClassPathXmlApplicationContext; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz; /** @@ -19,7 +34,9 @@ */ public class FizzBuzzTest { + // create a PrintStream called `out` private PrintStream out; + // create a FizBuzz objecct called `fb` private FizzBuzz fb; /** @@ -27,7 +44,9 @@ public class FizzBuzzTest { */ @Before public void setUp() { + // create a constant for the ApplicationContext called `context` that uses test constant `SPRING_XML` from TestConstants final ApplicationContext context = new ClassPathXmlApplicationContext(TestConstants.SPRING_XML); + // ... this.fb = (FizzBuzz) context.getBean(TestConstants.STANDARD_FIZZ_BUZZ); this.out = System.out; ((ConfigurableApplicationContext) context).close(); From 2d77fcccc2f34c64aa164aaaec77f88d45a6347a Mon Sep 17 00:00:00 2001 From: samr Date: Sat, 15 Oct 2022 11:39:37 -0700 Subject: [PATCH 2/7] Finished 5 files; worked on 2 files Also added patch-1-notes.md --- patch-1-notes.md | 15 +++++++ .../packagenamingpackage/impl/Constants.java | 18 ++++++++ .../packagenamingpackage/impl/Main.java | 11 +++++ .../impl/StandardFizzBuzz.java | 19 +++++++- .../impl/printers/IntegerIntegerPrinter.java | 11 +++++ .../interfaces/FizzBuzz.java | 6 ++- src/test/java/FizzBuzzTest.java | 1 + src/test/java/TestConstants.java | 45 +++++++++++++++++++ 8 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 patch-1-notes.md diff --git a/patch-1-notes.md b/patch-1-notes.md new file mode 100644 index 00000000..2e96163d --- /dev/null +++ b/patch-1-notes.md @@ -0,0 +1,15 @@ +# patch-1 Notes + +NOTE: This file is to be removed after all commenting is done. + +## DONE! + +- /test/java/FizzBuzzTest.java +- /test/java/TestConstants.java (!) +- /src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Constants.java (!) +- /src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/StandardFizzBuzz.java +- /src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/FizzBuzz.java + +## IN PROGRESS +- /src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Main.java +- /src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/printers/IntegerIntegerPrinter.java diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Constants.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Constants.java index f351e327..b646a9ef 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Constants.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Constants.java @@ -1,3 +1,7 @@ +// Constants.java +// Constants + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl; /** @@ -5,19 +9,33 @@ */ public class Constants { + // create constant for message if an attempt was made to divide by zero called `AN_ATTEMPT_WAS_MADE_TO_DIVIDE_BY_ZERO` which contains the string "An attempt was made to divide by zero." public static final String AN_ATTEMPT_WAS_MADE_TO_DIVIDE_BY_ZERO = "An attempt was made to divide by zero."; + // create constant for word "Buzz" called `BUZZ` public static final String BUZZ = "Buzz"; + // create constant for name of method `com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers.IntegerIntegerPrinter.print` called `COM_SERIOUSCOMPANY_BUSINESS_JAVA_FIZZBUZZ_PACKAGENAMINGPACKAGE_IMPL_PRINTERS_INTEGER_INTEGER_PRINTER_PRINT` which containt the string "com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers.IntegerIntegerPrinter.print()" public static final String COM_SERIOUSCOMPANY_BUSINESS_JAVA_FIZZBUZZ_PACKAGENAMINGPACKAGE_IMPL_PRINTERS_INTEGER_INTEGER_PRINTER_PRINT = "com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers.IntegerIntegerPrinter.print()"; + // create constant for word "Fizz" called `FIZZ` public static final String FIZZ = "Fizz"; + // create constant for the line seperator called `LINE_SEPERATOR` which contains the string "line.seperator" public static final String LINE_SEPARATOR = "line.separator"; + // create constant for the name of the loop component factory called `LOOP_COMPONENT_FACTORY` which contains the string "loopComponentFactory" public static final String LOOP_COMPONENT_FACTORY = "loopComponentFactory"; + // create constant for SPRING_XML which contains the string "spring.xml" public static final String SPRING_XML = "spring.xml"; + // create constant for STANDARD_FIZZ_BUZZ which contains the string "standardFizzBuzz" public static final String STANDARD_FIZZ_BUZZ = "standardFizzBuzz"; + // create constant for message if the integers could not be compared called `THE_INTEGERS_COULD_NOT_BE_COMPARED` which contains the string "The integers could not be compared." public static final String THE_INTEGERS_COULD_NOT_BE_COMPARED = "The integers could not be compared."; + // create constant for the default fizz buzz upper limit parameter value called `DEFAULT_FIZZ_BUZZ_UPPER_LIMIT_PARAMETER_VALUE` which contains the integer 100 public static final int DEFAULT_FIZZ_BUZZ_UPPER_LIMIT_PARAMETER_VALUE = 100; + // create constant for the integer divided by zero value called `INTEGER_DIVIDE_ZERO_VALUE` which contains the integer 0 public static final int INTEGER_DIVIDE_ZERO_VALUE = 0; + // create constant for the integer zero value called `INTEGER_ORIGIN_ZERO_VALUE` which contains the integer 0 public static final int INTEGER_ORIGIN_ZERO_VALUE = 0; + // create constant for the public static final int LOOP_INC_VALUE = 1; + // create constant for the <...> public static final int LOOP_INIT_VALUE = 1; } diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Main.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Main.java index 22409508..f2013a72 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Main.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Main.java @@ -1,11 +1,21 @@ +// Main.java +// Main + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl; +// imports org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContext; +// imports org.springframework.context.ConfigurableApplicationContext import org.springframework.context.ConfigurableApplicationContext; +// imports org.springframework.context.support.ClassPathXmlApplicationContext import org.springframework.context.support.ClassPathXmlApplicationContext; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.parameters.DefaultFizzBuzzUpperLimitParameter import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.parameters.DefaultFizzBuzzUpperLimitParameter; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.parameters.FizzBuzzUpperLimitParameter import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.parameters.FizzBuzzUpperLimitParameter; /** @@ -17,6 +27,7 @@ public final class Main { * @param args */ public static void main(final String[] args) { + // create a constant for the ApplicationContext called `context` that uses test constant `SPRING_XML` from Constants final ApplicationContext context = new ClassPathXmlApplicationContext(Constants.SPRING_XML); final FizzBuzz myFizzBuzz = (FizzBuzz) context.getBean(Constants.STANDARD_FIZZ_BUZZ); final FizzBuzzUpperLimitParameter fizzBuzzUpperLimit = new DefaultFizzBuzzUpperLimitParameter(); diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/StandardFizzBuzz.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/StandardFizzBuzz.java index acc15f54..3c1e5723 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/StandardFizzBuzz.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/StandardFizzBuzz.java @@ -1,10 +1,19 @@ +// StandardFizzBuzz.java +// Standard FizzBuzz + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl; +// imports org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired; +// imports org.springframework.stereotype.Service import org.springframework.stereotype.Service; +// com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.FizzBuzz; +// com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.FizzBuzzSolutionStrategyFactory import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.FizzBuzzSolutionStrategyFactory; +// com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.FizzBuzzSolutionStrategy import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.FizzBuzzSolutionStrategy; /** @@ -12,7 +21,8 @@ */ @Service public class StandardFizzBuzz implements FizzBuzz { - + + // create a private constant which uses FizzBuzzSolutionStrategyFactory called `_fizzBuzzSolutionStrategyFactory` private final FizzBuzzSolutionStrategyFactory _fizzBuzzSolutionStrategyFactory; /** @@ -20,7 +30,9 @@ public class StandardFizzBuzz implements FizzBuzz { */ @Autowired public StandardFizzBuzz(final FizzBuzzSolutionStrategyFactory _fizzBuzzSolutionStrategyFactory) { + // create a quick pointer `super` thing to access the accessor from the accessor method of the accessed object super(); + // initialize the attribute _fizzBuzzSolutionStrategy using param _fizzBuzzSolutionStrategy this._fizzBuzzSolutionStrategyFactory = _fizzBuzzSolutionStrategyFactory; } @@ -28,8 +40,11 @@ public StandardFizzBuzz(final FizzBuzzSolutionStrategyFactory _fizzBuzzSolutionS * @param nFizzBuzzUpperLimit */ public void fizzBuzz(final int nFizzBuzzUpperLimit) { + // create a constant which uses FizzBuzzSolutionStrategy called `mySolutionStrategy` final FizzBuzzSolutionStrategy mySolutionStrategy = - this._fizzBuzzSolutionStrategyFactory.createFizzBuzzSolutionStrategy(); + // set mySolutionStrategy to the returned value of the method `createFizzBuzzSolutionStrategy` from the class attribute `_fizzBuzzSolutionStrategyFactory` + this._fizzBuzzSolutionStrategyFactory.createFizzBuzzSolutionStrategy(); + // use the method runSolution with argument of parameter of nFizzBuzzUpperLimit from mySolutionStrategy mySolutionStrategy.runSolution(nFizzBuzzUpperLimit); } diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/printers/IntegerIntegerPrinter.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/printers/IntegerIntegerPrinter.java index f2ec3f83..121af42c 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/printers/IntegerIntegerPrinter.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/printers/IntegerIntegerPrinter.java @@ -1,12 +1,23 @@ +// Constants.java +// Constants + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers; +// imports org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired; +// imports org.springframework.stereotype.Service import org.springframework.stereotype.Service; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.IntegerIntegerStringReturnerFactory import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.IntegerIntegerStringReturnerFactory; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.SystemOutFizzBuzzOutputStrategyFactory import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.SystemOutFizzBuzzOutputStrategyFactory; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.adapters.FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.adapters.FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.printers.IntegerPrinter import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.printers.IntegerPrinter; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.stringreturners.IntegerStringReturner import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.stringreturners.IntegerStringReturner; /** diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/FizzBuzz.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/FizzBuzz.java index d0147978..21626516 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/FizzBuzz.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/FizzBuzz.java @@ -1,3 +1,7 @@ +// FizzBuzz.java +// FizzBuzz + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces; /** @@ -8,6 +12,6 @@ public interface FizzBuzz { /** * @param nFizzBuzzUpperLimit */ - void fizzBuzz(int nFizzBuzzUpperLimit); + void fizzBuzz(int nFizzBuzzUpperLimit); // create a method called `fizzBuzz` which returns void and has arguments of `nFizzBuzzUpperLimit` which is of type int } diff --git a/src/test/java/FizzBuzzTest.java b/src/test/java/FizzBuzzTest.java index c308e595..e6299632 100644 --- a/src/test/java/FizzBuzzTest.java +++ b/src/test/java/FizzBuzzTest.java @@ -45,6 +45,7 @@ public class FizzBuzzTest { @Before public void setUp() { // create a constant for the ApplicationContext called `context` that uses test constant `SPRING_XML` from TestConstants + // `SPRING_XML` points to /resources/assets/configuration/spring/dependencyinjection/configuration/spring.xml final ApplicationContext context = new ClassPathXmlApplicationContext(TestConstants.SPRING_XML); // ... this.fb = (FizzBuzz) context.getBean(TestConstants.STANDARD_FIZZ_BUZZ); diff --git a/src/test/java/TestConstants.java b/src/test/java/TestConstants.java index 6b8c5883..0bf875b4 100644 --- a/src/test/java/TestConstants.java +++ b/src/test/java/TestConstants.java @@ -1,45 +1,90 @@ +// TestConstants.java +// Test Constants for FizzBuzz + /** * Constants for FizzBuzz tests */ public class TestConstants { + // create a quick access access thing to access the accessor for the object class access private TestConstants() { + // create a quick pointer `super` thing to access the accessor from the accessor method of the accessed object super(); } + /* create constants for FizzBuzz Tests */ + // create constant for FizzBuzz up to 16 static final String _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14_FIZZ_BUZZ_16 = "1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\nFizzBuzz\n16\n"; + // create constant for FizzBuzz up to 15 static final String _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14_FIZZ_BUZZ = "1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\nFizzBuzz\n"; + // create constant for FizzBuzz up to 14 static final String _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14 = "1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n14\n"; + // create constant for FizzBuzz up to 13 static final String _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13 = "1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n13\n"; + // create constant for FizzBuzz up to 12 static final String _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ = "1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\nFizz\n"; + // create constant for FizzBuzz up to 11 static final String _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11 = "1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n11\n"; + // create constant for FizzBuzz up to 10 static final String _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ = "1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\nBuzz\n"; + // create constant for FizzBuzz up to 9 static final String _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ = "1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\nFizz\n"; + // create constant for FizzBuzz up to 8 static final String _1_2_FIZZ_4_BUZZ_FIZZ_7_8 = "1\n2\nFizz\n4\nBuzz\nFizz\n7\n8\n"; + // create constant for FizzBuzz up to 7 static final String _1_2_FIZZ_4_BUZZ_FIZZ_7 = "1\n2\nFizz\n4\nBuzz\nFizz\n7\n"; + // create constant for FizzBuzz up to 6 static final String _1_2_FIZZ_4_BUZZ_FIZZ = "1\n2\nFizz\n4\nBuzz\nFizz\n"; + // create constant for FizzBuzz up to 5 static final String _1_2_FIZZ_4_BUZZ = "1\n2\nFizz\n4\nBuzz\n"; + // create constant for FizzBuzz up to 4 static final String _1_2_FIZZ_4 = "1\n2\nFizz\n4\n"; + // create constant for FizzBuzz up to 3 static final String _1_2_FIZZ = "1\n2\nFizz\n"; + // create constant for FizzBuzz up to 2 static final String _1_2_ = "1\n2\n"; + // create constant for FizzBuzz up to 1 static final String _1_ = "1\n"; + + /* create constants for */ + // create constant for STANDARD_FIZZ_BUZZ which contains the string "standardFizzBuzz" static final String STANDARD_FIZZ_BUZZ = "standardFizzBuzz"; + // create constant for SPRING_XML which contains the string "spring.xml" + // NOTE points to /resources/assets/configuration/spring/dependencyinjection/configuration/spring.xml static final String SPRING_XML = "spring.xml"; + + /* create constants for integers */ + // create constant for integer 1 static final int INT_1 = 1; + // create constant for integer 2 static final int INT_2 = 2; + // create constant for integer 3 static final int INT_3 = 3; + // create constant for integer 4 static final int INT_4 = 4; + // create constant for integer 5 static final int INT_5 = 5; + // create constant for integer 6 static final int INT_6 = 6; + // create constant for integer 7 static final int INT_7 = 7; + // create constant for integer 8 static final int INT_8 = 8; + // create constant for integer 9 static final int INT_9 = 9; + // create constant for integer 10 static final int INT_10 = 10; + // create constant for integer 11 static final int INT_11 = 11; + // create constant for integer 12 static final int INT_12 = 12; + // create constant for integer 13 static final int INT_13 = 13; + // create constant for integer 14 static final int INT_14 = 14; + // create constant for integer 15 static final int INT_15 = 15; + // create constant for integer 16 static final int INT_16 = 16; } From bdf387cc8b81e699cb3bc4580899810f7cd3ba1f Mon Sep 17 00:00:00 2001 From: samr Date: Sun, 16 Oct 2022 10:26:42 -0700 Subject: [PATCH 3/7] Things and other things --- patch-1-notes.md | 45 ++++++++++++++++--- .../packagenamingpackage/impl/Main.java | 6 ++- .../NoFizzNoBuzzStrategyFactory.java | 15 ++++++- .../impl/printers/IntegerIntegerPrinter.java | 17 +++++-- .../FizzBuzzUpperLimitParameter.java | 4 ++ src/test/java/FizzBuzzTest.java | 29 +++++++++++- 6 files changed, 102 insertions(+), 14 deletions(-) diff --git a/patch-1-notes.md b/patch-1-notes.md index 2e96163d..1dc4c2ef 100644 --- a/patch-1-notes.md +++ b/patch-1-notes.md @@ -1,15 +1,46 @@ # patch-1 Notes -NOTE: This file is to be removed after all commenting is done. +This pull request be to fix issue #607. + +NOTE: This file be to be removed after all commenting be done. + + +ANOTHER NOTE: "<...>" be used to skip through many empty directories. +For example, "/src/<...>/impl" be used to direct the reader to +/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl. + +Another example, "/resources/<...>/spring.xml" be used to direct the reader to +/resources/assets/configuration/spring/dependencyinjection/configuration/spring.xml. ## DONE! +### /test/java + - /test/java/FizzBuzzTest.java - /test/java/TestConstants.java (!) -- /src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Constants.java (!) -- /src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/StandardFizzBuzz.java -- /src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/FizzBuzz.java -## IN PROGRESS -- /src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Main.java -- /src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/printers/IntegerIntegerPrinter.java +### /src/<...>/impl + +- /src/<...>/impl/Constants.java (!) +- /src/<...>/impl/StandardFizzBuzz.java +- /src/<...>/impl/Main.java + +#### /src/<...>/impl/printers + +- /src/<...>/impl/printers/IntegerIntegerPrinter.java + +#### /src/<...>/impl/factories + +- /src/<...>/impl/factories/NoFizzNoBuzzStrategyFactory.java + +### /src/<...>/interfaces + +- /src/<...>/interfaces/FizzBuzz.java + +#### /src/<...>/interfaces/parameters + +- /src/<...>/interfaces/parameters/FizzBuzzUpperLimitParameter.java + +## IN PROGRESS + +undefined diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Main.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Main.java index f2013a72..0ce6bd0e 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Main.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/Main.java @@ -27,12 +27,16 @@ public final class Main { * @param args */ public static void main(final String[] args) { - // create a constant for the ApplicationContext called `context` that uses test constant `SPRING_XML` from Constants + // create a constant for the ApplicationContext called `context` that uses constant `SPRING_XML` from Constants final ApplicationContext context = new ClassPathXmlApplicationContext(Constants.SPRING_XML); + // creates a constant using FizzBuzz called `myFizzBuzz` which accesses the constant `STANDARD_FIZZ_BUZZ` from Constants final FizzBuzz myFizzBuzz = (FizzBuzz) context.getBean(Constants.STANDARD_FIZZ_BUZZ); + // create a constant for the FizzBuzz Upper Limit using FizzBuzzUpperLimitParameter called `fizzBuzzUpperLimit` final FizzBuzzUpperLimitParameter fizzBuzzUpperLimit = new DefaultFizzBuzzUpperLimitParameter(); + // set myFizzBuzz.fizzBuzz to the FizzBuzz Upper Limit by using the obtainUpperLimitValue method from fizzBuzz UpperLimit myFizzBuzz.fizzBuzz(fizzBuzzUpperLimit.obtainUpperLimitValue()); + // close application context ((ConfigurableApplicationContext) context).close(); } diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/NoFizzNoBuzzStrategyFactory.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/NoFizzNoBuzzStrategyFactory.java index 800ca150..ea708a90 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/NoFizzNoBuzzStrategyFactory.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/NoFizzNoBuzzStrategyFactory.java @@ -1,10 +1,19 @@ +// NoFizzNoBuzzStrategyFactory.java +// Factory for NoFizzNoBuzzStrategy + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories; +// imports org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired; +// imports org.springframework.stereotype.Service import org.springframework.stereotype.Service; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.NoFizzNoBuzzStrategy import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.NoFizzNoBuzzStrategy; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.IsEvenlyDivisibleStrategyFactory import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.IsEvenlyDivisibleStrategyFactory; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.IsEvenlyDivisibleStrategy import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.IsEvenlyDivisibleStrategy; /** @@ -13,7 +22,8 @@ @Service public class NoFizzNoBuzzStrategyFactory implements IsEvenlyDivisibleStrategyFactory { - + + // creates private constant called `_noFizzNoBuzzStrategy` which uses `NoFizzNoBuzzStrategy` private final NoFizzNoBuzzStrategy _noFizzNoBuzzStrategy; /** @@ -21,7 +31,9 @@ public class NoFizzNoBuzzStrategyFactory implements */ @Autowired public NoFizzNoBuzzStrategyFactory(final NoFizzNoBuzzStrategy _noFizzNoBuzzStrategy) { + // create a quick pointer `super` thing to access the accessor from the accessor method of the accessed object super(); + // set attribute `_noFizzNoBuzzStrategy` to constant paraneter `_noFizzNozBuzzStrategy` this._noFizzNoBuzzStrategy = _noFizzNoBuzzStrategy; } @@ -30,6 +42,7 @@ public NoFizzNoBuzzStrategyFactory(final NoFizzNoBuzzStrategy _noFizzNoBuzzStrat */ @Override public IsEvenlyDivisibleStrategy createIsEvenlyDivisibleStrategy() { + // return the attribute `_noFizzNoBuzzStrategy` return this._noFizzNoBuzzStrategy; } diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/printers/IntegerIntegerPrinter.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/printers/IntegerIntegerPrinter.java index 121af42c..ab8ba423 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/printers/IntegerIntegerPrinter.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/printers/IntegerIntegerPrinter.java @@ -1,5 +1,5 @@ -// Constants.java -// Constants +// IntegerIntegerPrinter.java +// Printer for IntegerInteger // add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers; @@ -26,8 +26,10 @@ @Service public class IntegerIntegerPrinter implements IntegerPrinter { + // create instance of factory called SystemOutFizzBuzzOutputStrategyFactory called `_systemOutFizzBuzzOutputStrategyFactory` private final SystemOutFizzBuzzOutputStrategyFactory _systemOutFizzBuzzOutputStrategyFactory; + // create instance of factory called IntegerIntegerStringReturnerFactory called `_integerIntegerStringReturnerFactory` private final IntegerIntegerStringReturnerFactory _integerIntegerStringReturnerFactory; /** @@ -35,10 +37,13 @@ public class IntegerIntegerPrinter implements IntegerPrinter { * @param _systemOutFizzBuzzOutputStrategyFactory SystemOutFizzBuzzOutputStrategyFactory */ @Autowired - public IntegerIntegerPrinter(final IntegerIntegerStringReturnerFactory _integerIntegerStringReturnerFactory, + public IntegerIntegerPrinter(final IntegerIntegerStringReturnerFactory _integerIntegerStringReturnerFactory, // create constructor for IntegerIntegerPrinter final SystemOutFizzBuzzOutputStrategyFactory _systemOutFizzBuzzOutputStrategyFactory) { + // create a quick pointer `super` thing to access the accessor from the accessor method of the accessed object super(); + // sets the attribute `_integerIntegerStringReturnerFactory` to the value of the parameter called `_integerIntegerStringReturnerFactory` this._integerIntegerStringReturnerFactory = _integerIntegerStringReturnerFactory; + // sets the attribute `_systemOutFizzBuzzOutputStrategyFactory` to the value of the parameter called `_systemOutFizzBuzzOutputStrategyFactory` this._systemOutFizzBuzzOutputStrategyFactory = _systemOutFizzBuzzOutputStrategyFactory; } @@ -46,13 +51,17 @@ public IntegerIntegerPrinter(final IntegerIntegerStringReturnerFactory _integerI * @param theInteger */ public void printInteger(final int theInteger) { + // create a constant called `myIntegerStringReturner` using `IntegerStringReturner` which takes the value of the returned value of the method `createIntegerStringReturner` of attribute `_integerIntegerStringReturnerFactory` final IntegerStringReturner myIntegerStringReturner = this._integerIntegerStringReturnerFactory.createIntegerStringReturner(); + // create constant called `myIntegerString` of type String which takes the value of the returned value of the method `getIntegerReturnString` from `myIntegerStringReturner`. `getIntegerReturnString` from `myIntegerStringReturner` is passed the parameter `theInteger` final String myIntegerString = myIntegerStringReturner.getIntegerReturnString(theInteger); + // create a new `FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter` constant called `myOutputAdapter` which is passed the value of the return value of the method `createOutputStrategy` from attribute `_systemOutFizzBuzzOutputStrategyFactory` final FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter myOutputAdapter = new FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter( this._systemOutFizzBuzzOutputStrategyFactory.createOutputStrategy()); + // call method `output` from `FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter` called `myOutputAdapter` and pass the method `myIntegerString` myOutputAdapter.output(myIntegerString); } @@ -61,6 +70,7 @@ public void printInteger(final int theInteger) { */ @Override public void print() { + // throw an exception of type `UnsupportedOperationException` which takes the constant defined in `com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.Constants` called `COM_SERIOUSCOMPANY_BUSINESS_JAVA_FIZZBUZZ_PACKAGENAMINGPACKAGE_IMPL_PRINTERS_INTEGER_INTEGER_PRINTER_PRINT` which contains the string "com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers.IntegerIntegerPrinter.print()" throw new UnsupportedOperationException( com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.Constants.COM_SERIOUSCOMPANY_BUSINESS_JAVA_FIZZBUZZ_PACKAGENAMINGPACKAGE_IMPL_PRINTERS_INTEGER_INTEGER_PRINTER_PRINT); } @@ -70,6 +80,7 @@ public void print() { */ @Override public void printValue(final Object value) { + // call method `printInteger` and pass argument parameter constant `value` of type `Object` this.printInteger((Integer) value); } diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/parameters/FizzBuzzUpperLimitParameter.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/parameters/FizzBuzzUpperLimitParameter.java index 35b75231..a600e11a 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/parameters/FizzBuzzUpperLimitParameter.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/parameters/FizzBuzzUpperLimitParameter.java @@ -1,3 +1,7 @@ +// FizzBuzzUpperLimitParameter.java +// Parameter for FizzBuzzUpperList + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.parameters package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.parameters; /** diff --git a/src/test/java/FizzBuzzTest.java b/src/test/java/FizzBuzzTest.java index e6299632..d3b3cb37 100644 --- a/src/test/java/FizzBuzzTest.java +++ b/src/test/java/FizzBuzzTest.java @@ -45,11 +45,12 @@ public class FizzBuzzTest { @Before public void setUp() { // create a constant for the ApplicationContext called `context` that uses test constant `SPRING_XML` from TestConstants - // `SPRING_XML` points to /resources/assets/configuration/spring/dependencyinjection/configuration/spring.xml final ApplicationContext context = new ClassPathXmlApplicationContext(TestConstants.SPRING_XML); - // ... + // <...> this.fb = (FizzBuzz) context.getBean(TestConstants.STANDARD_FIZZ_BUZZ); + // set attribute `out` to instance of `PrintStream` type in package `System` called `System.out` this.out = System.out; + // close application context ((ConfigurableApplicationContext) context).close(); } @@ -58,6 +59,7 @@ public void setUp() { */ @After public void tearDown() { + // set the output stream to attribute `out` System.setOut(this.out); } @@ -67,14 +69,21 @@ public void tearDown() { * @throws IOException */ private void doFizzBuzz(final int n, final String s) throws IOException { + // create a constant called `baos` using `ByteArrayOutputStream` final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + // create a constant called `bos` using `BufferedOutputStream` and pass argument `baos` final BufferedOutputStream bos = new BufferedOutputStream(baos); + // set the output stream to `bos` System.setOut(new PrintStream(bos)); + // call the method `fizzBuzz` from the attribute `fb` and pass argument parameter constant `n` this.fb.fizzBuzz(n); + // flush the output stream System.out.flush(); + // create a string called `platformDependentExpectedResult` which takes parameter constant `s` and replaces all newlines with the proper system line seperator by getting property "line.seperator" from the `System` class from the package `java.util` String platformDependentExpectedResult = s.replaceAll("\\n", System.getProperty("line.separator")); + // assert if string `platformDependentExpectedResult` is an equal to `baos` as type string assertEquals(platformDependentExpectedResult, baos.toString()); } @@ -84,22 +93,38 @@ private void doFizzBuzz(final int n, final String s) throws IOException { */ @Test public void testFizzBuzz() throws IOException { + // run FizzBuzz test using test constant integer 1 and test constant FizzBuzz test _1_ this.doFizzBuzz(TestConstants.INT_1, TestConstants._1_); + // run FizzBuzz test using test constant integer 2 and test constant FizzBuzz test _1_2_ this.doFizzBuzz(TestConstants.INT_2, TestConstants._1_2_); + // run FizzBuzz test using test constant integer 3 and test constant FizzBuzz test _1_2_FIZZ this.doFizzBuzz(TestConstants.INT_3, TestConstants._1_2_FIZZ); + // run FizzBuzz test using test constant integer 4 and test constant FizzBuzz test _1_2_FIZZ_4 this.doFizzBuzz(TestConstants.INT_4, TestConstants._1_2_FIZZ_4); + // run FizzBuzz test using test constant integer 5 and test constant FizzBuzz test _1_2_FIZZ_4_BUZZ this.doFizzBuzz(TestConstants.INT_5, TestConstants._1_2_FIZZ_4_BUZZ); + // run FizzBuzz test using test constant integer 6 and test constant FizzBuzz test _1_2_FIZZ_4_BUZZ_FIZZ this.doFizzBuzz(TestConstants.INT_6, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ); + // run FizzBuzz test using test constant integer 7 and test constant FizzBuzz test _1_2_FIZZ_4_BUZZ_FIZZ_7 this.doFizzBuzz(TestConstants.INT_7, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7); + // run FizzBuzz test using test constant integer 8 and test constant FizzBuzz test _1_2_FIZZ_4_BUZZ_FIZZ_7_8 this.doFizzBuzz(TestConstants.INT_8, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8); + // run FizzBuzz test using test constant integer 9 and test constant FizzBuzz test _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ this.doFizzBuzz(TestConstants.INT_9, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ); + // run FizzBuzz test using test constant integer 10 and test constant FizzBuzz test _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ this.doFizzBuzz(TestConstants.INT_10, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ); + // run FizzBuzz test using test constant integer 11 and test constant FizzBuzz test _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11 this.doFizzBuzz(TestConstants.INT_11, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11); + // run FizzBuzz test using test constant integer 12 and test constant FizzBuzz test _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ this.doFizzBuzz(TestConstants.INT_12, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ); + // run FizzBuzz test using test constant integer 13 and test constant FizzBuzz test _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13 this.doFizzBuzz(TestConstants.INT_13, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13); + // run FizzBuzz test using test constant integer 14 and test constant FizzBuzz test _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14 this.doFizzBuzz(TestConstants.INT_14, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14); + // run FizzBuzz test using test constant integer 15 and test constant FizzBuzz test _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14_FIZZ_BUZZ this.doFizzBuzz(TestConstants.INT_15, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14_FIZZ_BUZZ); + // run FizzBuzz test using test constant integer 16 and test constant FizzBuzz test _1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14_FIZZ_BUZZ_16 this.doFizzBuzz(TestConstants.INT_16, TestConstants._1_2_FIZZ_4_BUZZ_FIZZ_7_8_FIZZ_BUZZ_11_FIZZ_13_14_FIZZ_BUZZ_16); } From 647873842218371a497104a31f0d922b218799f8 Mon Sep 17 00:00:00 2001 From: samr Date: Sun, 16 Oct 2022 10:46:46 -0700 Subject: [PATCH 4/7] Finished NoFizzNoBuzzStrategy and Printers --- patch-1-notes.md | 21 ++++++++++++++++--- .../impl/strategies/NoFizzNoBuzzStrategy.java | 17 +++++++++++++++ .../interfaces/printers/DataPrinter.java | 8 +++++-- .../interfaces/printers/IntegerPrinter.java | 6 +++++- .../interfaces/printers/StringPrinter.java | 6 +++++- 5 files changed, 51 insertions(+), 7 deletions(-) diff --git a/patch-1-notes.md b/patch-1-notes.md index 1dc4c2ef..1d7c35a0 100644 --- a/patch-1-notes.md +++ b/patch-1-notes.md @@ -5,11 +5,16 @@ This pull request be to fix issue #607. NOTE: This file be to be removed after all commenting be done. -ANOTHER NOTE: "<...>" be used to skip through many empty directories. -For example, "/src/<...>/impl" be used to direct the reader to +ANOTHER NOTE: +"<...>" be used to skip through many empty directories. +For example, +"/src/<...>/impl" +be used to direct the reader to /src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl. -Another example, "/resources/<...>/spring.xml" be used to direct the reader to +Another example, +"/resources/<...>/spring.xml" +be used to direct the reader to /resources/assets/configuration/spring/dependencyinjection/configuration/spring.xml. ## DONE! @@ -33,6 +38,10 @@ Another example, "/resources/<...>/spring.xml" be used to direct the reader to - /src/<...>/impl/factories/NoFizzNoBuzzStrategyFactory.java +#### /src/<...>/impl/strategies + +- /src/<...>/impl/strategies/NoFizzNoBuzzStrategy.java + ### /src/<...>/interfaces - /src/<...>/interfaces/FizzBuzz.java @@ -41,6 +50,12 @@ Another example, "/resources/<...>/spring.xml" be used to direct the reader to - /src/<...>/interfaces/parameters/FizzBuzzUpperLimitParameter.java +### /src/<...>/interfaces/printers + +- /src/<...>/interfaces/printers/DataPrinter.java +- /src/<...>/interfaces/printers/StringPrinter.java +- /src/<...>/interfaces/printers/IntegerPrinter.java + ## IN PROGRESS undefined diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/strategies/NoFizzNoBuzzStrategy.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/strategies/NoFizzNoBuzzStrategy.java index c9ead5cc..f1b9f8e6 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/strategies/NoFizzNoBuzzStrategy.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/strategies/NoFizzNoBuzzStrategy.java @@ -1,9 +1,17 @@ +// NoFizzNoBuzzStrategy.java +// Strategy for NoFizzNoBuzz + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies; +// imports org.springframework.stereotype.Service import org.springframework.stereotype.Service; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.IsEvenlyDivisibleStrategy import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.IsEvenlyDivisibleStrategy; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.constants.NoFizzNoBuzzStrategyConstants import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.constants.NoFizzNoBuzzStrategyConstants; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.math.arithmetics.NumberIsMultipleOfAnotherNumberVerifier import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.math.arithmetics.NumberIsMultipleOfAnotherNumberVerifier; /** @@ -17,23 +25,32 @@ public class NoFizzNoBuzzStrategy implements IsEvenlyDivisibleStrategy { * @return boolean */ public boolean isEvenlyDivisible(final int theInteger) { + // call the method `numberIsMultipleOfAnotherNumber` from `NumberIsMultipleOfAnotherNumberVerifier` and pass argument parameter constant `theInteger` and argument constant `NO_FIZZ_INTEGER_CONSTANT_VALUE` from `NoFizzNoBuzzStrategyConstants` if (!NumberIsMultipleOfAnotherNumberVerifier.numberIsMultipleOfAnotherNumber(theInteger, NoFizzNoBuzzStrategyConstants.NO_FIZZ_INTEGER_CONSTANT_VALUE)) { + // if number is multiple of another number is not true, call the method numberIsMultipleOfAnotherNumber` from `NumberIsMultipleOfAnotherNumberVerifier` and pass argument parameter constant `theInteger` and argument constant `NO_BUZZ_INTEGER_CONSTANT_VALUE` from `NoFizzNoBuzzStrategyConstants` if (!NumberIsMultipleOfAnotherNumberVerifier.numberIsMultipleOfAnotherNumber(theInteger, NoFizzNoBuzzStrategyConstants.NO_BUZZ_INTEGER_CONSTANT_VALUE)) { + // if number is multiple of another number is not true, return true return true; } else { + // otherwise, return false return false; } } else if (!NumberIsMultipleOfAnotherNumberVerifier.numberIsMultipleOfAnotherNumber(theInteger, NoFizzNoBuzzStrategyConstants.NO_BUZZ_INTEGER_CONSTANT_VALUE)) { + // if number is multiple of another number is not not true, call the method numberIsMultipleOfAnotherNumber` from `NumberIsMultipleOfAnotherNumberVerifier` and pass argument parameter constant `theInteger` and argument constant `NO_BUZZ_INTEGER_CONSTANT_VALUE` from `NoFizzNoBuzzStrategyConstants` + // call the method numberIsMultipleOfAnotherNumber` from `NumberIsMultipleOfAnotherNumberVerifier` and pass argument parameter constant `theInteger` and argument constant `NO_FIZZ_INTEGER_CONSTANT_VALUE` from `NoFizzNoBuzzStrategyConstants` if (!NumberIsMultipleOfAnotherNumberVerifier.numberIsMultipleOfAnotherNumber(theInteger, NoFizzNoBuzzStrategyConstants.NO_FIZZ_INTEGER_CONSTANT_VALUE)) { + // if number is multiple of another number is not true, return true return true; } else { + // otherwise, return false return false; } } else { + // otherwise, return false return false; } } diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/printers/DataPrinter.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/printers/DataPrinter.java index 7627df06..c505a333 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/printers/DataPrinter.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/printers/DataPrinter.java @@ -1,3 +1,7 @@ +// DataPrinter.java +// Printer for Data + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.printers package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.printers; /** @@ -8,11 +12,11 @@ public interface DataPrinter { /** * @return */ - public void print(); + public void print(); // create a method to print which returns void and takes no parameters /** * @param value */ - public void printValue(Object value); + public void printValue(Object value); // create a method to print a value which returns void and takes an Object parameter called `value` } diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/printers/IntegerPrinter.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/printers/IntegerPrinter.java index e011bfa7..c84a37c2 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/printers/IntegerPrinter.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/printers/IntegerPrinter.java @@ -1,3 +1,7 @@ +// IntegerPrinter.java +// Printer for Integer + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.printers package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.printers; /** @@ -8,6 +12,6 @@ public interface IntegerPrinter extends DataPrinter { /** * @param theInteger */ - public void printInteger(int theInteger); + public void printInteger(int theInteger); // create a method to print integers which returns void and takes an int parameter called `theInteger` } diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/printers/StringPrinter.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/printers/StringPrinter.java index 001aeab4..dd304f37 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/printers/StringPrinter.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/interfaces/printers/StringPrinter.java @@ -1,3 +1,7 @@ +// StringPrinter.java +// Printer for String + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.printers package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.printers; /** @@ -8,6 +12,6 @@ public interface StringPrinter extends DataPrinter { /** * */ - public void print(); + public void print(); // create a method to print which returns void and takes no parameters } From 1d7554cecd9c7d3c876bca1673f332cb273dba0c Mon Sep 17 00:00:00 2001 From: samr Date: Sun, 16 Oct 2022 11:25:45 -0700 Subject: [PATCH 5/7] Factories --- patch-1-notes.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/patch-1-notes.md b/patch-1-notes.md index 1d7c35a0..99471b8e 100644 --- a/patch-1-notes.md +++ b/patch-1-notes.md @@ -37,6 +37,10 @@ be used to direct the reader to #### /src/<...>/impl/factories - /src/<...>/impl/factories/NoFizzNoBuzzStrategyFactory.java +- /src/<...>/impl/factories/BuzzStrategyFactory.java +- /src/<...>/impl/factories/BuzzStringPrinterFactory.java +- /src/<...>/impl/factories/BuzzStringReturnerFactory.java +- /src/<...>/impl/factories/EnterpriseGradeFizzBuzzSolutionStrategy.java #### /src/<...>/impl/strategies @@ -59,3 +63,4 @@ be used to direct the reader to ## IN PROGRESS undefined + From 1dd19706523c340279dc12352fdf6bd6be1de570 Mon Sep 17 00:00:00 2001 From: samr Date: Sun, 16 Oct 2022 11:26:01 -0700 Subject: [PATCH 6/7] Factories --- .../impl/factories/BuzzStrategyFactory.java | 14 ++++++++++++++ .../impl/factories/BuzzStringPrinterFactory.java | 15 +++++++++++++++ .../impl/factories/BuzzStringReturnerFactory.java | 14 ++++++++++++++ ...priseGradeFizzBuzzSolutionStrategyFactory.java | 13 +++++++++++++ 4 files changed, 56 insertions(+) diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/BuzzStrategyFactory.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/BuzzStrategyFactory.java index 9ae2367b..8069b1a5 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/BuzzStrategyFactory.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/BuzzStrategyFactory.java @@ -1,10 +1,19 @@ +// BuzzStrategyFactory.java +// Factory for BuzzStrategy + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories; +// imports org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired; +// imports org.springframework.stereotype.Service import org.springframework.stereotype.Service; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.BuzzStrategy import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.BuzzStrategy; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.IsEvenlyDivisibleStrategyFactory import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.IsEvenlyDivisibleStrategyFactory; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.IsEvenlyDivisibleFactory import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.IsEvenlyDivisibleStrategy; /** @@ -13,14 +22,18 @@ @Service public class BuzzStrategyFactory implements IsEvenlyDivisibleStrategyFactory { + // create a private constant using BuzzStrategy called `_buzzStrategy` with no value private final BuzzStrategy _buzzStrategy; /** * @param _buzzStrategy BuzzStrategy */ @Autowired + // create constructor public BuzzStrategyFactory(final BuzzStrategy _buzzStrategy) { + // create a quick pointer `super` thing to access the accessor from the accessor method of the accessed object super(); + // set the attribute `_buzzStrategy` to the parameter constant `buzzStrategy` of type BuzzStrategy this._buzzStrategy = _buzzStrategy; } @@ -29,6 +42,7 @@ public BuzzStrategyFactory(final BuzzStrategy _buzzStrategy) { */ @Override public IsEvenlyDivisibleStrategy createIsEvenlyDivisibleStrategy() { + // return the attribute `_buzzStrategy` return this._buzzStrategy; } diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/BuzzStringPrinterFactory.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/BuzzStringPrinterFactory.java index 82f352f5..4457b794 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/BuzzStringPrinterFactory.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/BuzzStringPrinterFactory.java @@ -1,10 +1,19 @@ +// BuzzStringPrinterFactory.java +// Faactory for BuzzStringPrinter + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories; +// imports org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired; +// imports org.springframework.stereotype.Service import org.springframework.stereotype.Service; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers.BuzzStringPrinter import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers.BuzzStringPrinter; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.StringPrinterFactory import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.StringPrinterFactory; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.printers.StringPrinter import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.printers.StringPrinter; /** @@ -13,14 +22,18 @@ @Service public class BuzzStringPrinterFactory implements StringPrinterFactory { + // create a private constant using BuzzStringPrinter called `_buzzStringPrinter` with no value private final BuzzStringPrinter _buzzStringPrinter; /** * @param _buzzStringPrinter BuzzStringPrinter */ @Autowired + // create constructor public BuzzStringPrinterFactory(final BuzzStringPrinter _buzzStringPrinter) { + // create a quick pointer `super` thing to access the accessor from the accessor method of the accessed object super(); + // set attribute `_buzzStringPrinter` to parameter constant `_buzzStringParameter` this._buzzStringPrinter = _buzzStringPrinter; } @@ -28,7 +41,9 @@ public BuzzStringPrinterFactory(final BuzzStringPrinter _buzzStringPrinter) { * @return StringPrinter */ @Override + // create public method called `createStringPrinter` which returns type StringPrinter public StringPrinter createStringPrinter() { + // return attribute `_buzzStringPrinter` return this._buzzStringPrinter; } diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/BuzzStringReturnerFactory.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/BuzzStringReturnerFactory.java index 94a5fb2c..98eb4d9b 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/BuzzStringReturnerFactory.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/BuzzStringReturnerFactory.java @@ -1,10 +1,19 @@ +// BuzzStringReturnerFactory.java +// Factory for BuzzStringReturner + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories; +// imports org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired; +// imports org.springframework.stereotype.Service import org.springframework.stereotype.Service; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.stringreturners.BuzzStringReturner import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.stringreturners.BuzzStringReturner; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.StringStringReturnerFactory import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.StringStringReturnerFactory; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.stringreturners.StringStringReturner import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.stringreturners.StringStringReturner; /** @@ -13,14 +22,18 @@ @Service public class BuzzStringReturnerFactory implements StringStringReturnerFactory { + // create a private constant the uses BuzzStringReturner called `_myBuzzStringReturner` private final BuzzStringReturner _myBuzzStringReturner; /** * @param _myBuzzStringReturner BuzzStringReturner */ @Autowired + // create a constructor that take a constant final parameter called `_myBuzzStringReturner` of type BuzzStringReturner public BuzzStringReturnerFactory(final BuzzStringReturner _myBuzzStringReturner) { + // create a quick pointer `super` thing to access the accessor from the accessor method of the accessed object super(); + // set attribute `_myBuzzStringReturner` to parameter constant `_myBuzzStringReturner` this._myBuzzStringReturner = _myBuzzStringReturner; } @@ -29,6 +42,7 @@ public BuzzStringReturnerFactory(final BuzzStringReturner _myBuzzStringReturner) */ @Override public StringStringReturner createStringStringReturner() { + // return attribute `_myBuzzStringReturner` return this._myBuzzStringReturner; } diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/EnterpriseGradeFizzBuzzSolutionStrategyFactory.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/EnterpriseGradeFizzBuzzSolutionStrategyFactory.java index 7fc9c987..08b0c6a9 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/EnterpriseGradeFizzBuzzSolutionStrategyFactory.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/factories/EnterpriseGradeFizzBuzzSolutionStrategyFactory.java @@ -1,9 +1,17 @@ +// EnterpriseGradeFizzBuzzSolutionStrategyFactory +// Factory for EnterpriseGradeFizzBuzzSolutionStrategy + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories; +// imports org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Autowired; +// imports the Service class from the steretype package from the springframework package from the org package import org.springframework.stereotype.Service; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.FizzBuzzSolutionFactory import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.factories.FizzBuzzSolutionStrategyFactory; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.FizzBuzzSolutionStrategy import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.strategies.FizzBuzzSolutionStrategy; /** @@ -12,14 +20,18 @@ @Service public class EnterpriseGradeFizzBuzzSolutionStrategyFactory implements FizzBuzzSolutionStrategyFactory { + // create a private constant which uses `FizzBuzzSolutionStrategy` called `_fizzBuzzSolutionStrategy` private final FizzBuzzSolutionStrategy _fizzBuzzSolutionStrategy; /** * @param _fizzBuzzSolutionStrategy FizzBuzzSolutionStrategy */ @Autowired + // create a constructor which take a constant parameter called `_fizzBuzzSolutionStrategy` of type FizzBuzzSolutionStrategy public EnterpriseGradeFizzBuzzSolutionStrategyFactory(final FizzBuzzSolutionStrategy _fizzBuzzSolutionStrategy) { + // create a quick pointer `super` thing to access the accessor from the accessor method of the accessed object super(); + // set attribute `_fizzBuzzSolutionStrategy` to argument parameter constant `_fizzBuzzSolutionStrategy` this._fizzBuzzSolutionStrategy = _fizzBuzzSolutionStrategy; } @@ -28,6 +40,7 @@ public EnterpriseGradeFizzBuzzSolutionStrategyFactory(final FizzBuzzSolutionStra */ @Override public FizzBuzzSolutionStrategy createFizzBuzzSolutionStrategy() { + // return attribute `_fizzBuzzSolutionStrategy` return this._fizzBuzzSolutionStrategy; } From 6fe14bd7e937a43c3215f881a0c3ba07ad876244 Mon Sep 17 00:00:00 2001 From: samr Date: Thu, 10 Nov 2022 12:36:04 -0800 Subject: [PATCH 7/7] finished LoopCondition.java --- patch-1-notes.md | 11 +++++++---- .../impl/loop/LoopCondition.java | 13 +++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/patch-1-notes.md b/patch-1-notes.md index 99471b8e..62965400 100644 --- a/patch-1-notes.md +++ b/patch-1-notes.md @@ -4,9 +4,9 @@ This pull request be to fix issue #607. NOTE: This file be to be removed after all commenting be done. - ANOTHER NOTE: "<...>" be used to skip through many empty directories. + For example, "/src/<...>/impl" be used to direct the reader to @@ -17,7 +17,7 @@ Another example, be used to direct the reader to /resources/assets/configuration/spring/dependencyinjection/configuration/spring.xml. -## DONE! +## COMPLETED ### /test/java @@ -46,6 +46,10 @@ be used to direct the reader to - /src/<...>/impl/strategies/NoFizzNoBuzzStrategy.java +#### /src/<...>/impl/loop + +- /src/<...>/impl/loop/LoopCondition.java + ### /src/<...>/interfaces - /src/<...>/interfaces/FizzBuzz.java @@ -62,5 +66,4 @@ be used to direct the reader to ## IN PROGRESS -undefined - +null diff --git a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/loop/LoopCondition.java b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/loop/LoopCondition.java index 0cdadafb..1c17cbfd 100644 --- a/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/loop/LoopCondition.java +++ b/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/loop/LoopCondition.java @@ -1,8 +1,15 @@ +// LoopCondition.java +// LoopCondition + +// add to package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.loop package com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.loop; +// imports org.springframework.stereotype.Service import org.springframework.stereotype.Service; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.comparators.integercomparator.ThreeWayIntegerComparator import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.comparators.integercomparator.ThreeWayIntegerComparator; +// imports com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.comparators.integercomparator.ThreeWayIntegerComparator import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.comparators.integercomparator.ThreeWayIntegerComparisonResult; /** @@ -17,8 +24,14 @@ public class LoopCondition { * @return boolean */ public boolean evaluateLoop(final int nCurrentNumber, final int nTotalCount) { + // create a constant called `comparisonResult` with the type of `ThreeWayIntegerComparisonResult` which has the value of the returned value of the method `Compare` from the class `ThreeWayIntegerCompare` and gets passed the constant parameter argument value of `nCurrentNumber` of type int and the constant parameter argument value of `nTotalCount` of type int final ThreeWayIntegerComparisonResult comparisonResult = ThreeWayIntegerComparator.Compare(nCurrentNumber, nTotalCount); + // check if the value `FirstIsLessThanSecond` is equal to the constant `comparisonResult` of type `ThreeWayIntegerComparisonResult` + // if it is, return true + // otherwise, check if the value `FirstEqualsSecond` is equal to the constant `comparisonResult` of type `ThreeWayIntegerComparisonResult` + // if it is, return true + // otherwise, return false if (ThreeWayIntegerComparisonResult.FirstIsLessThanSecond == comparisonResult) { return true; } else if (ThreeWayIntegerComparisonResult.FirstEqualsSecond == comparisonResult) {