diff --git a/src/main/java/it/unimi/di/prog2/e15/IntRangeClient.java b/src/main/java/it/unimi/di/prog2/e15/IntRangeClient.java
new file mode 100644
index 00000000..0730cf96
--- /dev/null
+++ b/src/main/java/it/unimi/di/prog2/e15/IntRangeClient.java
@@ -0,0 +1,85 @@
+/*
+
+Copyright 2024 Massimo Santini
+
+This file is part of "Programmazione 2 @ UniMI" teaching material.
+
+This is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This material 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this file. If not, see .
+
+*/
+
+package it.unimi.di.prog2.e15;
+
+/** A class to test int ranges. */
+public class IntRangeClient {
+
+ /** . */
+ private IntRangeClient() {}
+
+ /**
+ * A method to test the {@link IntRange} class.
+ *
+ *
This methods reads the parameters of an {@link IntRange} from the lines in the standard
+ * input in the form {@code command value}, where the command is:
+ *
+ *
+ * - {@code F} to set the from value of the range.
+ *
- {@code T} to set the to value of the range.
+ *
- {@code S} to set the step of the range.
+ *
+ *
+ * commands can be repeated, the last value is the one that is considered; the default values for
+ * from, to and step are respectively {@link Integer#MIN_VALUE}, {@link Integer#MAX_VALUE}, and 1.
+ * Once the input is exhausted, the method emits in a single line of the standard output:
+ *
+ *
+ * - the number of integers in the range,
+ *
- the first integer in the range (if any),
+ *
- the last integer in the range (if different from the first).
+ *
+ *
+ * @param args not used.
+ */
+
+ /*- Uncomment and complete once you have implemented the range class
+
+ public static void main(String[] args) {
+ // declare the range...
+ try (Scanner sc = new Scanner(System.in)) {
+ while (sc.hasNext()) {
+ char command = sc.next().charAt(0);
+ int value = sc.nextInt();
+ switch (command) {
+ case 'F':
+ // set the from the range
+ break;
+ case 'T':
+ // set the to the range
+ break;
+ case 'S':
+ // set the step the range
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown command: " + command);
+ }
+ }
+ }
+ int iterations = 0, first = 0, last = 0;
+ // complete...
+ System.out.println(
+ iterations + (iterations > 0 ? " " + first : "") + (iterations > 1 ? " " + last : ""));
+ }
+
+ */
+}
diff --git a/src/main/java/it/unimi/di/prog2/e15/StringIterators.java b/src/main/java/it/unimi/di/prog2/e15/StringIterators.java
new file mode 100644
index 00000000..05d13681
--- /dev/null
+++ b/src/main/java/it/unimi/di/prog2/e15/StringIterators.java
@@ -0,0 +1,77 @@
+/*
+
+Copyright 2024 Massimo Santini
+
+This file is part of "Programmazione 2 @ UniMI" teaching material.
+
+This is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This material 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this file. If not, see .
+
+*/
+
+package it.unimi.di.prog2.e15;
+
+import java.util.Iterator;
+
+/** Utility class with some string iterators. */
+public class StringIterators {
+
+ /** . */
+ private StringIterators() {}
+
+ /**
+ * Filters even-positioned strings.
+ *
+ * @param it an iterator of strings.
+ * @return an iterator that returns the even-positioned strings of {@code it}.
+ */
+ public static Iterator evenIterator(final Iterator it) {
+ return new Iterator<>() {
+
+ // EXERCISE: complete the implementation
+
+ @Override
+ public boolean hasNext() {
+ throw new UnsupportedOperationException("Unimplemented method 'hasNext'");
+ }
+
+ @Override
+ public String next() {
+ throw new UnsupportedOperationException("Unimplemented method 'next'");
+ }
+ };
+ }
+
+ /**
+ * Converts strings to uppercase.
+ *
+ * @param it an iterator of strings.
+ * @return an iterator that returns the strings of {@code it} in uppercase.
+ */
+ public static Iterator uppercase(final Iterator it) {
+ return new Iterator<>() {
+
+ // EXERCISE: complete the implementation
+
+ @Override
+ public boolean hasNext() {
+ throw new UnsupportedOperationException("Unimplemented method 'hasNext'");
+ }
+
+ @Override
+ public String next() {
+ throw new UnsupportedOperationException("Unimplemented method 'next'");
+ }
+ };
+ }
+}
diff --git a/src/main/java/it/unimi/di/prog2/e15/StringIteratorsClient.java b/src/main/java/it/unimi/di/prog2/e15/StringIteratorsClient.java
new file mode 100644
index 00000000..85e48c16
--- /dev/null
+++ b/src/main/java/it/unimi/di/prog2/e15/StringIteratorsClient.java
@@ -0,0 +1,44 @@
+/*
+
+Copyright 2024 Massimo Santini
+
+This file is part of "Programmazione 2 @ UniMI" teaching material.
+
+This is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This material 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this file. If not, see .
+
+*/
+
+package it.unimi.di.prog2.e15;
+
+/** A class to test {@link StringIterators}. */
+public class StringIteratorsClient {
+
+ /** . */
+ private StringIteratorsClient() {}
+
+ /**
+ * Prints the uppercase version of the even lines of the standard input.
+ *
+ * @param args not used.
+ */
+ /*- uncomment the following code once you have implemented the methods in StringIterators
+
+ public static void main(String[] args) {
+ try (Scanner s = new Scanner(System.in)) {
+ Iterator it = StringIterators.uppercase(StringIterators.evenIterator(s));
+ while (it.hasNext()) System.out.println(it.next());
+ }
+ }
+ */
+}
diff --git a/src/main/java/it/unimi/di/prog2/e15/package-info.java b/src/main/java/it/unimi/di/prog2/e15/package-info.java
new file mode 100644
index 00000000..fc3edad9
--- /dev/null
+++ b/src/main/java/it/unimi/di/prog2/e15/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * Esercizi relativi alla lezione 15, per maggiori dettagli si veda il diario del corso.
+ */
+package it.unimi.di.prog2.e15;
diff --git a/src/main/java/it/unimi/di/prog2/h14/IntSet.java b/src/main/java/it/unimi/di/prog2/h14/IntSet.java
index 4e96dd83..57081b14 100644
--- a/src/main/java/it/unimi/di/prog2/h14/IntSet.java
+++ b/src/main/java/it/unimi/di/prog2/h14/IntSet.java
@@ -49,13 +49,6 @@ public class IntSet implements Iterable {
*
*/
- private boolean repOk() {
- for (int i = 0; i < els.size(); i++)
- for (int j = 0; j < els.size(); j++)
- if (i != j && els.get(i).equals(els.get(j))) return false;
- return true;
- }
-
/**
* Initializes this set to be empty.
*
@@ -72,7 +65,7 @@ public IntSet() {
* @param other the {@code IntSet} to copy from.
*/
public IntSet(IntSet other) {
- els = new ArrayList(other.els);
+ els = new ArrayList<>(other.els);
assert repOk();
}
@@ -177,4 +170,16 @@ public String toString() {
public Iterator iterator() {
return new IntGenerator(els);
}
+
+ /**
+ * An implementation of the RI.
+ *
+ * @return whether the RI is satisfied.
+ */
+ private boolean repOk() {
+ for (int i = 0; i < els.size(); i++)
+ for (int j = 0; j < els.size(); j++)
+ if (i != j && els.get(i).equals(els.get(j))) return false;
+ return true;
+ }
}
diff --git a/src/main/java/it/unimi/di/prog2/h14/IntSetsClient.java b/src/main/java/it/unimi/di/prog2/h14/IntSetsClient.java
index 7c4fc400..cfdc5a73 100644
--- a/src/main/java/it/unimi/di/prog2/h14/IntSetsClient.java
+++ b/src/main/java/it/unimi/di/prog2/h14/IntSetsClient.java
@@ -25,6 +25,7 @@
/** Classe per il test di {@link IntSet} {@link IntGenerator}. */
public class IntSetsClient {
+ /** . */
private IntSetsClient() {}
/**
diff --git a/src/main/java/it/unimi/di/prog2/h14/Primes.java b/src/main/java/it/unimi/di/prog2/h14/Primes.java
index 93a2537e..7fd42e00 100644
--- a/src/main/java/it/unimi/di/prog2/h14/Primes.java
+++ b/src/main/java/it/unimi/di/prog2/h14/Primes.java
@@ -28,6 +28,9 @@
/** Iteratore che genera i numeri primi. */
public class Primes implements Iterator {
+ /** Crea un generatore di numeri primi. */
+ public Primes() {}
+
/*-
* AF: il prossimo numero primo è il primo intero maggiore o uguale a
* candidate che non sia divisibile per uno dei primi già restituiti da next,
diff --git a/src/main/java/it/unimi/di/prog2/h15/DecimalDigits.java b/src/main/java/it/unimi/di/prog2/h15/DecimalDigits.java
new file mode 100644
index 00000000..184d1de6
--- /dev/null
+++ b/src/main/java/it/unimi/di/prog2/h15/DecimalDigits.java
@@ -0,0 +1,51 @@
+/*
+
+Copyright 2024 Massimo Santini
+
+This file is part of "Programmazione 2 @ UniMI" teaching material.
+
+This is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This material 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this file. If not, see .
+
+*/
+
+package it.unimi.di.prog2.h15;
+
+/** A class representing decimal digits of a long. */
+public class DecimalDigits {
+
+ /** The number whose digits are represented by this class. */
+ private final long number;
+
+ /**
+ * Creates a new instance representing the digits of the given number.
+ *
+ * @param number the number.
+ */
+ public DecimalDigits(final long number) {
+ this.number = number;
+ }
+
+ /**
+ * Returns the digit corresponding to the given power of 10.
+ *
+ * @param power the power.
+ * @return the corresponding digit.
+ */
+ public int digit(final int power) {
+ if (power < 0) throw new IllegalArgumentException("The power must be positive.");
+ long digit = number;
+ for (int i = 0; i < power; i++) digit /= 10;
+ return (int) (digit % 10);
+ }
+}
diff --git a/src/main/java/it/unimi/di/prog2/h15/DecimalDigitsAG.java b/src/main/java/it/unimi/di/prog2/h15/DecimalDigitsAG.java
new file mode 100644
index 00000000..c537c564
--- /dev/null
+++ b/src/main/java/it/unimi/di/prog2/h15/DecimalDigitsAG.java
@@ -0,0 +1,73 @@
+/*
+
+Copyright 2024 Massimo Santini
+
+This file is part of "Programmazione 2 @ UniMI" teaching material.
+
+This is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This material 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this file. If not, see .
+
+*/
+
+package it.unimi.di.prog2.h15;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * A class representing decimal digits of a long, endowed with a non zero digits iterator, based on
+ * an anonymous class.
+ */
+public class DecimalDigitsAG {
+
+ /** The number whose digits are represented by this class. */
+ private final long number;
+
+ /**
+ * Creates a new instance representing the digits of the given number.
+ *
+ * @param number the number.
+ */
+ public DecimalDigitsAG(final long number) {
+ this.number = number;
+ }
+
+ /**
+ * Returns a generator on from the least significant to the most significant non zero
+ * digits.
+ *
+ * @return the generator.
+ */
+ public Iterator nonZeroDigits() {
+ // no need to pass any value, nor to define any named class
+ return new Iterator() {
+
+ /** The remaining digits to return (except possibly for the trailing zeroes). */
+ private long remaining = number;
+
+ @Override
+ public boolean hasNext() {
+ while (remaining != 0 && remaining % 10 == 0) remaining /= 10;
+ return remaining != 0;
+ }
+
+ @Override
+ public Integer next() {
+ if (!hasNext()) throw new NoSuchElementException();
+ int digit = (int) (remaining % 10);
+ remaining /= 10;
+ return digit;
+ }
+ };
+ }
+}
diff --git a/src/main/java/it/unimi/di/prog2/h15/DecimalDigitsEG.java b/src/main/java/it/unimi/di/prog2/h15/DecimalDigitsEG.java
new file mode 100644
index 00000000..f4523a65
--- /dev/null
+++ b/src/main/java/it/unimi/di/prog2/h15/DecimalDigitsEG.java
@@ -0,0 +1,67 @@
+/*
+
+Copyright 2024 Massimo Santini
+
+This file is part of "Programmazione 2 @ UniMI" teaching material.
+
+This is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This material 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this file. If not, see .
+
+*/
+
+package it.unimi.di.prog2.h15;
+
+import java.util.Iterator;
+
+/**
+ * A class representing decimal digits of a long, endowed with a non zero digits iterator, based on
+ * the external {@link NonZeroDigitsGenerator} class.
+ */
+public class DecimalDigitsEG {
+
+ /** The number whose digits are represented by this class. */
+ private final long number;
+
+ /**
+ * Creates a new instance representing the digits of the given number.
+ *
+ * @param number the number.
+ */
+ public DecimalDigitsEG(final long number) {
+ this.number = number;
+ }
+
+ /**
+ * Returns the digit corresponding to the given power of 10.
+ *
+ * @param power the power.
+ * @return the corresponding digit.
+ */
+ public int digit(final int power) {
+ if (power < 0) throw new IllegalArgumentException("The power must be positive.");
+ long digit = number;
+ for (int i = 0; i < power; i++) digit /= 10;
+ return (int) (digit % 10);
+ }
+
+ /**
+ * Returns a generator on from the least significant to the most significant non zero
+ * digits.
+ *
+ * @return the generator.
+ */
+ public Iterator nonZeroDigits() {
+ // we expose the representation to an external class
+ return new NonZeroDigitsGenerator(number);
+ }
+}
diff --git a/src/main/java/it/unimi/di/prog2/h15/DecimalDigitsIG.java b/src/main/java/it/unimi/di/prog2/h15/DecimalDigitsIG.java
new file mode 100644
index 00000000..fe436707
--- /dev/null
+++ b/src/main/java/it/unimi/di/prog2/h15/DecimalDigitsIG.java
@@ -0,0 +1,94 @@
+/*
+
+Copyright 2024 Massimo Santini
+
+This file is part of "Programmazione 2 @ UniMI" teaching material.
+
+This is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This material 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this file. If not, see .
+
+*/
+
+package it.unimi.di.prog2.h15;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * A class representing decimal digits of a long, endowed with a non zero digits iterator, based on
+ * the inner {@link DecimalDigitsIG.NonZeroDigitsGeneratorIG
+ * NonZeroDigitsGeneratorIG} class
+ */
+public class DecimalDigitsIG {
+
+ /** The number whose digits are represented by this class. */
+ private final long number;
+
+ /**
+ * Creates a new instance representing the digits of the given number.
+ *
+ * @param number the number.
+ */
+ public DecimalDigitsIG(final long number) {
+ this.number = number;
+ }
+
+ /**
+ * Returns the digit corresponding to the given power of 10.
+ *
+ * @param power the power.
+ * @return the corresponding digit.
+ */
+ public int digit(final int power) {
+ if (power < 0) throw new IllegalArgumentException("The power must be positive.");
+ long digit = number;
+ for (int i = 0; i < power; i++) digit /= 10;
+ return (int) (digit % 10);
+ }
+
+ /** An inner class implementing the generator. */
+ private class NonZeroDigitsGeneratorIG implements Iterator {
+
+ /** . */
+ private NonZeroDigitsGeneratorIG() {}
+
+ /** The remaining digits to return (except possibly for the trailing zeroes). */
+ private long remaining = number;
+
+ @Override
+ public boolean hasNext() {
+ while (remaining != 0 && remaining % 10 == 0) remaining /= 10;
+ return remaining != 0;
+ }
+
+ @Override
+ public Integer next() {
+ if (!hasNext()) throw new NoSuchElementException();
+ int digit = (int) (remaining % 10);
+ remaining /= 10;
+ return digit;
+ }
+ }
+
+ /**
+ * Returns a generator on from the least significant to the most significant non zero
+ * digits.
+ *
+ * @return the generator.
+ */
+ public Iterator nonZeroDigits() {
+ // no need to pass any value: the representation is shared among this class
+ // and the inner generator
+ return new NonZeroDigitsGeneratorIG();
+ }
+}
diff --git a/src/main/java/it/unimi/di/prog2/h15/DecimalDigitsNSG.java b/src/main/java/it/unimi/di/prog2/h15/DecimalDigitsNSG.java
new file mode 100644
index 00000000..d9808dd6
--- /dev/null
+++ b/src/main/java/it/unimi/di/prog2/h15/DecimalDigitsNSG.java
@@ -0,0 +1,99 @@
+/*
+
+Copyright 2024 Massimo Santini
+
+This file is part of "Programmazione 2 @ UniMI" teaching material.
+
+This is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This material 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this file. If not, see .
+
+*/
+
+package it.unimi.di.prog2.h15;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * A class representing decimal digits of a long, endowed with a non zero digits iterator, based on
+ * the nested static {@link DecimalDigitsNSG.NonZeroDigitsGeneratorNS
+ * NonZeroDigitsGeneratorNS} class.
+ */
+public class DecimalDigitsNSG {
+
+ /** The number whose digits are represented by this class. */
+ private final long number;
+
+ /**
+ * Creates a new instance representing the digits of the given number.
+ *
+ * @param number the number.
+ */
+ public DecimalDigitsNSG(final long number) {
+ this.number = number;
+ }
+
+ /**
+ * Returns the digit corresponding to the given power of 10.
+ *
+ * @param power the power.
+ * @return the corresponding digit.
+ */
+ public int digit(final int power) {
+ if (power < 0) throw new IllegalArgumentException("The power must be positive.");
+ long digit = number;
+ for (int i = 0; i < power; i++) digit /= 10;
+ return (int) (digit % 10);
+ }
+
+ /** A nested static class implementing the genrator. */
+ private static class NonZeroDigitsGeneratorNS implements Iterator {
+
+ /** The remaining digits to return (except possibly for the trailing zeroes). */
+ private long remaining;
+
+ /**
+ * Creates a new generator for the given number.
+ *
+ * @param number the number.
+ */
+ private NonZeroDigitsGeneratorNS(final long number) {
+ remaining = number;
+ }
+
+ @Override
+ public boolean hasNext() {
+ while (remaining != 0 && remaining % 10 == 0) remaining /= 10;
+ return remaining != 0;
+ }
+
+ @Override
+ public Integer next() {
+ if (!hasNext()) throw new NoSuchElementException();
+ int digit = (int) (remaining % 10);
+ remaining /= 10;
+ return digit;
+ }
+ }
+
+ /**
+ * Returns a generator on from the least significant to the most significant non zero
+ * digits.
+ *
+ * @return the generator.
+ */
+ public Iterator nonZeroDigits() {
+ // we "expose" the representation, albeit just to a nested static class
+ return new NonZeroDigitsGeneratorNS(number);
+ }
+}
diff --git a/src/main/java/it/unimi/di/prog2/h15/NonZeroDigitsGenerator.java b/src/main/java/it/unimi/di/prog2/h15/NonZeroDigitsGenerator.java
new file mode 100644
index 00000000..ce516256
--- /dev/null
+++ b/src/main/java/it/unimi/di/prog2/h15/NonZeroDigitsGenerator.java
@@ -0,0 +1,57 @@
+/*
+
+Copyright 2024 Massimo Santini
+
+This file is part of "Programmazione 2 @ UniMI" teaching material.
+
+This is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This material 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this file. If not, see .
+
+*/
+
+package it.unimi.di.prog2.h15;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+/**
+ * A generator returning the non zero digits of a long from the least to the most significant one.
+ */
+public class NonZeroDigitsGenerator implements Iterator {
+
+ /** The remaining digits to return (except possibly for the trailing zeroes). */
+ private long remaining;
+
+ /**
+ * Creates a new generator for the given number.
+ *
+ * @param number the number.
+ */
+ protected NonZeroDigitsGenerator(final long number) {
+ remaining = number;
+ }
+
+ @Override
+ public boolean hasNext() {
+ while (remaining != 0 && remaining % 10 == 0) remaining /= 10;
+ return remaining != 0;
+ }
+
+ @Override
+ public Integer next() {
+ if (!hasNext()) throw new NoSuchElementException();
+ int digit = (int) (remaining % 10);
+ remaining /= 10;
+ return digit;
+ }
+}
diff --git a/src/main/java/it/unimi/di/prog2/h15/package-info.java b/src/main/java/it/unimi/di/prog2/h15/package-info.java
new file mode 100644
index 00000000..d5a318a2
--- /dev/null
+++ b/src/main/java/it/unimi/di/prog2/h15/package-info.java
@@ -0,0 +1,22 @@
+/**
+ * Codice relativo alla lezione 15 per maggiori dettagli si veda il diario del corso.
+ *
+ * In this package there are several variants of a {@link DecimalDigits}, a class that can be
+ * used to compute the digits of the decimal expansion of a given number.
+ *
+ *
All the variants are endowed in addition with an iterator (that is a method that
+ * returns a generator in Lisokv's parlance) on non zero digits; the variants correspond to
+ * various possibilities with regard to the implementation style of the generator:
+ *
+ *
+ * - {@link DecimalDigitsEG} based on the external class {@link
+ * NonZeroDigitsGenerator},
+ *
- {@link DecimalDigitsNSG} based on a nested static class,
+ *
- {@link DecimalDigitsIG} based on an inner class,
+ *
- {@link DecimalDigitsAG} based on an anonymous class.
+ *
+ *
+ * Such variants are listed in increasing order of preferableness (and implementation complexity).
+ */
+package it.unimi.di.prog2.h15;
diff --git a/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-1.txt b/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-1.txt
new file mode 100644
index 00000000..00659e68
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-1.txt
@@ -0,0 +1 @@
+4 3 9
diff --git a/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-2.txt b/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-2.txt
new file mode 100644
index 00000000..5a8b6d44
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-2.txt
@@ -0,0 +1 @@
+3 10 4
diff --git a/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-3.txt b/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-3.txt
new file mode 100644
index 00000000..1b991dd6
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-3.txt
@@ -0,0 +1 @@
+3 -2147480648 -2147482648
diff --git a/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-4.txt b/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-4.txt
new file mode 100644
index 00000000..737e5fd5
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-4.txt
@@ -0,0 +1 @@
+5 2147483637 2147483645
diff --git a/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-5.txt b/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-5.txt
new file mode 100644
index 00000000..573541ac
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-5.txt
@@ -0,0 +1 @@
+0
diff --git a/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-6.txt b/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-6.txt
new file mode 100644
index 00000000..aba06649
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/IntRangeClient/expected-6.txt
@@ -0,0 +1 @@
+1 10
diff --git a/tests/it/unimi/di/prog2/e15/IntRangeClient/input-1.txt b/tests/it/unimi/di/prog2/e15/IntRangeClient/input-1.txt
new file mode 100644
index 00000000..859a5d5e
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/IntRangeClient/input-1.txt
@@ -0,0 +1,3 @@
+F 3
+T 10
+S 2
\ No newline at end of file
diff --git a/tests/it/unimi/di/prog2/e15/IntRangeClient/input-2.txt b/tests/it/unimi/di/prog2/e15/IntRangeClient/input-2.txt
new file mode 100644
index 00000000..d4049b5c
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/IntRangeClient/input-2.txt
@@ -0,0 +1,3 @@
+F 10
+T 2
+S -3
\ No newline at end of file
diff --git a/tests/it/unimi/di/prog2/e15/IntRangeClient/input-3.txt b/tests/it/unimi/di/prog2/e15/IntRangeClient/input-3.txt
new file mode 100644
index 00000000..14b19013
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/IntRangeClient/input-3.txt
@@ -0,0 +1,3 @@
+F -2147480648
+T -2147483648
+S -1000
diff --git a/tests/it/unimi/di/prog2/e15/IntRangeClient/input-4.txt b/tests/it/unimi/di/prog2/e15/IntRangeClient/input-4.txt
new file mode 100644
index 00000000..498f5c59
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/IntRangeClient/input-4.txt
@@ -0,0 +1,2 @@
+F 2147483637
+S 2
\ No newline at end of file
diff --git a/tests/it/unimi/di/prog2/e15/IntRangeClient/input-5.txt b/tests/it/unimi/di/prog2/e15/IntRangeClient/input-5.txt
new file mode 100644
index 00000000..93ac0d92
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/IntRangeClient/input-5.txt
@@ -0,0 +1,2 @@
+F 10
+T 10
diff --git a/tests/it/unimi/di/prog2/e15/IntRangeClient/input-6.txt b/tests/it/unimi/di/prog2/e15/IntRangeClient/input-6.txt
new file mode 100644
index 00000000..3a2058d9
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/IntRangeClient/input-6.txt
@@ -0,0 +1,3 @@
+F 10
+T 12
+S 2
\ No newline at end of file
diff --git a/tests/it/unimi/di/prog2/e15/StringIteratorsClient/expected-1.txt b/tests/it/unimi/di/prog2/e15/StringIteratorsClient/expected-1.txt
new file mode 100644
index 00000000..8c10b980
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/StringIteratorsClient/expected-1.txt
@@ -0,0 +1,4 @@
+CINQUE
+OTTO
+NOVE
+DODICI
diff --git a/tests/it/unimi/di/prog2/e15/StringIteratorsClient/input-1.txt b/tests/it/unimi/di/prog2/e15/StringIteratorsClient/input-1.txt
new file mode 100644
index 00000000..cb0e730e
--- /dev/null
+++ b/tests/it/unimi/di/prog2/e15/StringIteratorsClient/input-1.txt
@@ -0,0 +1,12 @@
+uno
+due
+tre
+quattro
+cinque
+sei
+sette
+otto
+nove
+dieci
+unidici
+dodici