diff --git a/pom.xml b/pom.xml index 40aa671..1e5a276 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ mattrixwv myClasses - 1.0.1 + 1.2.0 myClasses www.mattrixwv.com diff --git a/src/main/java/mattrixwv/ArrayAlgorithms.java b/src/main/java/com/mattrixwv/ArrayAlgorithms.java similarity index 99% rename from src/main/java/mattrixwv/ArrayAlgorithms.java rename to src/main/java/com/mattrixwv/ArrayAlgorithms.java index b3cc995..8c1e606 100644 --- a/src/main/java/mattrixwv/ArrayAlgorithms.java +++ b/src/main/java/com/mattrixwv/ArrayAlgorithms.java @@ -19,7 +19,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -package mattrixwv; +package com.mattrixwv; import java.math.BigInteger; diff --git a/src/main/java/mattrixwv/NumberAlgorithms.java b/src/main/java/com/mattrixwv/NumberAlgorithms.java similarity index 99% rename from src/main/java/mattrixwv/NumberAlgorithms.java rename to src/main/java/com/mattrixwv/NumberAlgorithms.java index 5ba19a4..7a95562 100644 --- a/src/main/java/mattrixwv/NumberAlgorithms.java +++ b/src/main/java/com/mattrixwv/NumberAlgorithms.java @@ -19,7 +19,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -package mattrixwv; +package com.mattrixwv; import java.math.BigInteger; @@ -29,7 +29,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; -import mattrixwv.exceptions.InvalidResult; +import com.mattrixwv.exceptions.InvalidResult; public class NumberAlgorithms{ diff --git a/src/main/java/mattrixwv/Stopwatch.java b/src/main/java/com/mattrixwv/Stopwatch.java similarity index 98% rename from src/main/java/mattrixwv/Stopwatch.java rename to src/main/java/com/mattrixwv/Stopwatch.java index 6b84463..d6968a6 100644 --- a/src/main/java/mattrixwv/Stopwatch.java +++ b/src/main/java/com/mattrixwv/Stopwatch.java @@ -19,10 +19,10 @@ Copyright (C) 2022 Matthew Ellison You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -package mattrixwv; +package com.mattrixwv; -import mattrixwv.exceptions.InvalidResult; +import com.mattrixwv.exceptions.InvalidResult; public class Stopwatch{ diff --git a/src/main/java/mattrixwv/StringAlgorithms.java b/src/main/java/com/mattrixwv/StringAlgorithms.java similarity index 99% rename from src/main/java/mattrixwv/StringAlgorithms.java rename to src/main/java/com/mattrixwv/StringAlgorithms.java index 2b824e9..089a9a5 100644 --- a/src/main/java/mattrixwv/StringAlgorithms.java +++ b/src/main/java/com/mattrixwv/StringAlgorithms.java @@ -19,7 +19,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -package mattrixwv; +package com.mattrixwv; import java.util.ArrayList; diff --git a/src/main/java/com/mattrixwv/Triple.java b/src/main/java/com/mattrixwv/Triple.java new file mode 100644 index 0000000..e5b74e8 --- /dev/null +++ b/src/main/java/com/mattrixwv/Triple.java @@ -0,0 +1,67 @@ +//JavaClasses/src/main/java/com/mattrixwv/Triple.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +//This class implements a triplet of variables +/* +Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv; + + +public class Triple{ + private T a; + private U b; + private V c; + + public Triple(T a, U b, V c){ + this.a = a; + this.b = b; + this.c = c; + } + + public T getA(){ + return a; + } + public U getB(){ + return b; + } + public V getC(){ + return c; + } + + @Override + public boolean equals(Object o){ + if(this == o){ + return true; + } + else if(o instanceof Triple){ + Triple rightSide = (Triple)o; + return (a.equals(rightSide.a) && b.equals(rightSide.b) && c.equals(rightSide.c)); + } + else{ + return false; + } + } + @Override + public int hashCode(){ + return a.hashCode() + b.hashCode() * c.hashCode(); + } + @Override + public String toString(){ + return "[" + a.toString() + ", " + b.toString() + ", " + c.toString() + "]"; + } +} diff --git a/src/main/java/mattrixwv/exceptions/InvalidResult.java b/src/main/java/com/mattrixwv/exceptions/InvalidResult.java similarity index 92% rename from src/main/java/mattrixwv/exceptions/InvalidResult.java rename to src/main/java/com/mattrixwv/exceptions/InvalidResult.java index e769fd0..2f57c90 100644 --- a/src/main/java/mattrixwv/exceptions/InvalidResult.java +++ b/src/main/java/com/mattrixwv/exceptions/InvalidResult.java @@ -3,7 +3,7 @@ // Created: 08-24-20 //Modified: 08-24-20 //This is an exception for an invalid result out of one of my algorithms -package mattrixwv.exceptions; +package com.mattrixwv.exceptions; public class InvalidResult extends Exception{ diff --git a/src/main/java/com/mattrixwv/generators/HexagonalNumberGenerator.java b/src/main/java/com/mattrixwv/generators/HexagonalNumberGenerator.java new file mode 100644 index 0000000..e516b65 --- /dev/null +++ b/src/main/java/com/mattrixwv/generators/HexagonalNumberGenerator.java @@ -0,0 +1,57 @@ +//JavaClasses/src/main/java/mattrixwv/HexagonalNumberGenerator.java +//Matthew Ellison +// Created: 08-20-22 +//Modified: 08-20-22 +//This class generates hexagonal numbers +/* +Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv.generators; + + +import java.util.Iterator; +import java.util.NoSuchElementException; + + +public class HexagonalNumberGenerator implements Iterator{ + private Long num; + + public HexagonalNumberGenerator(){ + num = 1L; + } + + @Override + public boolean hasNext(){ + return (2 * num * num) > 0; + } + + @Override + public Long next(){ + Long newNum = ((2 * num * num) - num); + ++num; + if(num > 0){ + return newNum; + } + else{ + throw new NoSuchElementException("Number overflow"); + } + } + + public static boolean isHexagonal(Long x){ + Long n = Math.round((Math.sqrt(1 + (8 * x)) + 1) / 4); + return ((2 * n * n) - n) == x; + } +} diff --git a/src/main/java/com/mattrixwv/generators/PentagonalNumberGenerator.java b/src/main/java/com/mattrixwv/generators/PentagonalNumberGenerator.java new file mode 100644 index 0000000..1d9d19e --- /dev/null +++ b/src/main/java/com/mattrixwv/generators/PentagonalNumberGenerator.java @@ -0,0 +1,57 @@ +//JavaClasses/src/main/java/com/mattrixwv/generators/PentagonalNumberGenerator.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +//This class generates pentagonal numbers +/* +Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv.generators; + + +import java.util.Iterator; +import java.util.NoSuchElementException; + + +public class PentagonalNumberGenerator implements Iterator{ + private Long num; + + public PentagonalNumberGenerator(){ + num = 1L; + } + + @Override + public boolean hasNext(){ + return (3 * num * num) > 0; + } + + @Override + public Long next(){ + long newNum = ((3 * num * num) - num) / 2; + ++num; + if(num > 0){ + return newNum; + } + else{ + throw new NoSuchElementException("Number overflow"); + } + } + + public static boolean isPentagonal(Long x){ + Long n = Math.round((Math.sqrt(1 + (24 * x)) + 1) / 6); + return (((3 * n * n) - n) / 2) == x; + } +} diff --git a/src/main/java/mattrixwv/SieveOfEratosthenes.java b/src/main/java/com/mattrixwv/generators/SieveOfEratosthenes.java similarity index 98% rename from src/main/java/mattrixwv/SieveOfEratosthenes.java rename to src/main/java/com/mattrixwv/generators/SieveOfEratosthenes.java index fd17cf6..724b151 100644 --- a/src/main/java/mattrixwv/SieveOfEratosthenes.java +++ b/src/main/java/com/mattrixwv/generators/SieveOfEratosthenes.java @@ -19,7 +19,7 @@ Copyright (C) 2022 Matthew Ellison You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -package mattrixwv; +package com.mattrixwv.generators; import java.util.ArrayList; diff --git a/src/main/java/mattrixwv/SieveOfEratosthenesBig.java b/src/main/java/com/mattrixwv/generators/SieveOfEratosthenesBig.java similarity index 98% rename from src/main/java/mattrixwv/SieveOfEratosthenesBig.java rename to src/main/java/com/mattrixwv/generators/SieveOfEratosthenesBig.java index b903789..3828a69 100644 --- a/src/main/java/mattrixwv/SieveOfEratosthenesBig.java +++ b/src/main/java/com/mattrixwv/generators/SieveOfEratosthenesBig.java @@ -19,7 +19,7 @@ Copyright (C) 2022 Matthew Ellison You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -package mattrixwv; +package com.mattrixwv.generators; import java.math.BigInteger; diff --git a/src/main/java/com/mattrixwv/generators/TriangularNumberGenerator.java b/src/main/java/com/mattrixwv/generators/TriangularNumberGenerator.java new file mode 100644 index 0000000..bbcb524 --- /dev/null +++ b/src/main/java/com/mattrixwv/generators/TriangularNumberGenerator.java @@ -0,0 +1,57 @@ +//JavaClasses/src/main/java/com/mattrixwv/generators/TriangularNumberGenerator.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +//This class generates triangular numbers +/* +Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv.generators; + + +import java.util.Iterator; +import java.util.NoSuchElementException; + + +public class TriangularNumberGenerator implements Iterator{ + private Long num; + + public TriangularNumberGenerator(){ + num = 1L; + } + + @Override + public boolean hasNext(){ + return (num * num) > 0; + } + + @Override + public Long next(){ + Long newNum = ((num * num) + num) / 2; + ++num; + if(num > 0){ + return newNum; + } + else{ + throw new NoSuchElementException("Number overflow"); + } + } + + public static boolean isTriangular(Long x){ + Long n = Math.round((Math.sqrt(1 + (8 * x)) - 1) / 2); + return (((n * n) + n) / 2) == x; + } +} diff --git a/src/test/java/mattrixwv/TestArrayAlgorithms.java b/src/test/java/com/mattrixwv/TestArrayAlgorithms.java similarity index 99% rename from src/test/java/mattrixwv/TestArrayAlgorithms.java rename to src/test/java/com/mattrixwv/TestArrayAlgorithms.java index 2d7452e..86c7b67 100644 --- a/src/test/java/mattrixwv/TestArrayAlgorithms.java +++ b/src/test/java/com/mattrixwv/TestArrayAlgorithms.java @@ -19,7 +19,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -package mattrixwv; +package com.mattrixwv; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/mattrixwv/TestNumberAlgorithms.java b/src/test/java/com/mattrixwv/TestNumberAlgorithms.java similarity index 99% rename from src/test/java/mattrixwv/TestNumberAlgorithms.java rename to src/test/java/com/mattrixwv/TestNumberAlgorithms.java index ec5bcfb..2a862ed 100644 --- a/src/test/java/mattrixwv/TestNumberAlgorithms.java +++ b/src/test/java/com/mattrixwv/TestNumberAlgorithms.java @@ -19,7 +19,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -package mattrixwv; +package com.mattrixwv; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -33,7 +33,7 @@ import java.util.List; import org.junit.jupiter.api.Test; -import mattrixwv.exceptions.InvalidResult; +import com.mattrixwv.exceptions.InvalidResult; public class TestNumberAlgorithms{ diff --git a/src/test/java/mattrixwv/TestStopwatch.java b/src/test/java/com/mattrixwv/TestStopwatch.java similarity index 98% rename from src/test/java/mattrixwv/TestStopwatch.java rename to src/test/java/com/mattrixwv/TestStopwatch.java index c0f315c..b27de1c 100644 --- a/src/test/java/mattrixwv/TestStopwatch.java +++ b/src/test/java/com/mattrixwv/TestStopwatch.java @@ -22,7 +22,7 @@ Copyright (C) 2022 Matthew Ellison */ -package mattrixwv; +package com.mattrixwv; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import org.junit.jupiter.api.Test; -import mattrixwv.exceptions.InvalidResult; +import com.mattrixwv.exceptions.InvalidResult; public class TestStopwatch{ diff --git a/src/test/java/mattrixwv/TestStringAlgorithms.java b/src/test/java/com/mattrixwv/TestStringAlgorithms.java similarity index 99% rename from src/test/java/mattrixwv/TestStringAlgorithms.java rename to src/test/java/com/mattrixwv/TestStringAlgorithms.java index 660a9a6..43fc25c 100644 --- a/src/test/java/mattrixwv/TestStringAlgorithms.java +++ b/src/test/java/com/mattrixwv/TestStringAlgorithms.java @@ -19,7 +19,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -package mattrixwv; +package com.mattrixwv; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/com/mattrixwv/TestTriple.java b/src/test/java/com/mattrixwv/TestTriple.java new file mode 100644 index 0000000..7f96ae7 --- /dev/null +++ b/src/test/java/com/mattrixwv/TestTriple.java @@ -0,0 +1,45 @@ +//JavaClasses/src/test/java/com/mattrixwv/TestTriple.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +/* + Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv; + + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + + +public class TestTriple{ + @Test + public void testTriple(){ + Triple longTriple1 = new Triple(1L, 2L, 3L); + Triple longTriple2 = new Triple(1L, 2L, 3L); + Triple longTriple3 = new Triple(3L, 2L, 1L); + assertEquals(1L, longTriple1.getA()); + assertEquals(2L, longTriple1.getB()); + assertEquals(3L, longTriple1.getC()); + assertEquals(true, longTriple1.equals(longTriple1)); + assertEquals(true, longTriple1.equals(longTriple2)); + assertEquals(false, longTriple1.equals(longTriple3)); + assertEquals(false, longTriple1.equals(1L)); + assertEquals(Long.hashCode(1) + Long.hashCode(2) * Long.hashCode(3), longTriple1.hashCode()); + assertEquals("[1, 2, 3]", longTriple1.toString()); + } +} diff --git a/src/test/java/com/mattrixwv/generators/TestHexagonalNumberGenerator.java b/src/test/java/com/mattrixwv/generators/TestHexagonalNumberGenerator.java new file mode 100644 index 0000000..00d743c --- /dev/null +++ b/src/test/java/com/mattrixwv/generators/TestHexagonalNumberGenerator.java @@ -0,0 +1,47 @@ +//JavaClasses/src/test/java/com/mattrixwv/generators/TestHexagonalNumberGenerator.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +/* +Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv.generators; + + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.junit.jupiter.api.Test; + + +public class TestHexagonalNumberGenerator{ + @Test + public void hexagonalNumberGeneratorTest(){ + HexagonalNumberGenerator gen = new HexagonalNumberGenerator(); + List nums = Arrays.asList(1L, 6L, 15L, 28L, 45L, 66L, 91L, 120L, 153L); + ArrayList generatedNums = new ArrayList<>(); + for(int cnt = 0;cnt < nums.size();++cnt){ + generatedNums.add(gen.next()); + } + assertEquals(nums, generatedNums); + assertEquals(true, gen.hasNext()); + assertEquals(true, HexagonalNumberGenerator.isHexagonal(153L)); + assertEquals(false, HexagonalNumberGenerator.isHexagonal(154L)); + } +} diff --git a/src/test/java/com/mattrixwv/generators/TestPentagonalNumberGenerator.java b/src/test/java/com/mattrixwv/generators/TestPentagonalNumberGenerator.java new file mode 100644 index 0000000..619cab4 --- /dev/null +++ b/src/test/java/com/mattrixwv/generators/TestPentagonalNumberGenerator.java @@ -0,0 +1,47 @@ +//JavaClasses/src/test/java/com/mattrixwv/generators/TestPentagonalNumberGenerator.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +/* +Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv.generators; + + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.junit.jupiter.api.Test; + + +public class TestPentagonalNumberGenerator{ + @Test + public void pentagonalNumberGeneratorTest(){ + PentagonalNumberGenerator gen = new PentagonalNumberGenerator(); + List nums = Arrays.asList(1L, 5L, 12L, 22L, 35L, 51L, 70L, 92L, 117L); + ArrayList generatedNums = new ArrayList<>(); + for(int cnt = 0;cnt < nums.size();++cnt){ + generatedNums.add(gen.next()); + } + assertEquals(nums, generatedNums); + assertEquals(true, gen.hasNext()); + assertEquals(true, PentagonalNumberGenerator.isPentagonal(117L)); + assertEquals(false, PentagonalNumberGenerator.isPentagonal(118L)); + } +} diff --git a/src/test/java/mattrixwv/TestSieveOfEratosthenes.java b/src/test/java/com/mattrixwv/generators/TestSieveOfEratosthenes.java similarity index 98% rename from src/test/java/mattrixwv/TestSieveOfEratosthenes.java rename to src/test/java/com/mattrixwv/generators/TestSieveOfEratosthenes.java index f354ea7..4142eda 100644 --- a/src/test/java/mattrixwv/TestSieveOfEratosthenes.java +++ b/src/test/java/com/mattrixwv/generators/TestSieveOfEratosthenes.java @@ -19,7 +19,7 @@ Copyright (C) 2022 Matthew Ellison You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ -package mattrixwv; +package com.mattrixwv.generators; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/com/mattrixwv/generators/TestTriangularNumberGenerator.java b/src/test/java/com/mattrixwv/generators/TestTriangularNumberGenerator.java new file mode 100644 index 0000000..df76db9 --- /dev/null +++ b/src/test/java/com/mattrixwv/generators/TestTriangularNumberGenerator.java @@ -0,0 +1,47 @@ +//JavaClasses/src/test/java/com/mattrixwv/generators/TestTriangularNumberGenerator.java +//Mattrixwv +// Created: 08-20-22 +//Modified: 08-20-22 +/* +Copyright (C) 2022 Matthew Ellison + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . +*/ +package com.mattrixwv.generators; + + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.junit.jupiter.api.Test; + + +public class TestTriangularNumberGenerator{ + @Test + public void triangularNumberGeneratorTest(){ + TriangularNumberGenerator gen = new TriangularNumberGenerator(); + List nums = Arrays.asList(1L, 3L, 6L, 10L, 15L, 21L, 28L, 36L, 45L); + ArrayList generatedNums = new ArrayList<>(); + for(int cnt = 0;cnt < nums.size();++cnt){ + generatedNums.add(gen.next()); + } + assertEquals(nums, generatedNums); + assertEquals(true, gen.hasNext()); + assertEquals(true, TriangularNumberGenerator.isTriangular(55L)); + assertEquals(false, TriangularNumberGenerator.isTriangular(54L)); + } +}