2016-01-13 21:45:13 +00:00
|
|
|
package de.janchristiangruenhage.demo.math.multiplication;
|
|
|
|
|
|
|
|
import de.janchristiangruenhage.math.multiplication.LongMultiplication;
|
2016-01-14 11:40:43 +00:00
|
|
|
import de.janchristiangruenhage.util.MultiOutput;
|
|
|
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
import java.io.PrintWriter;
|
2016-01-13 21:45:13 +00:00
|
|
|
|
|
|
|
public class Main {
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
2016-01-14 11:40:43 +00:00
|
|
|
String factorOne = "";
|
|
|
|
//Constructs the factorOne string
|
|
|
|
for (int i = 0; i < 20; i++) {
|
|
|
|
factorOne += (char) (48 + ((int) (Math.random() * 10)));
|
|
|
|
//adds a random number character to the factorOne string
|
|
|
|
}
|
|
|
|
String factorTwo = "";
|
|
|
|
//Constructs the factorTwo string
|
|
|
|
for (int i = 0; i < 5; i++) {
|
|
|
|
factorTwo += (char) (48 + ((int) (Math.random() * 10)));
|
|
|
|
//adds a random number character to the factorTwo string
|
|
|
|
}
|
|
|
|
MultiOutput output = getOutputs(factorOne, factorTwo);
|
|
|
|
//gets the output for these factors;
|
|
|
|
output.println(new LongMultiplication(factorOne, factorTwo, 50, 0).printCalculation());
|
|
|
|
//prints the calculation
|
|
|
|
}
|
|
|
|
|
|
|
|
private static MultiOutput getOutputs(String factorOne, String factorTwo) {
|
|
|
|
MultiOutput output = new MultiOutput();
|
|
|
|
output.add(System.out);
|
|
|
|
try {
|
|
|
|
output.add(new PrintWriter(("Multiplication" + factorOne.hashCode() + factorTwo.hashCode())));
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
return output;
|
2016-01-13 21:45:13 +00:00
|
|
|
}
|
|
|
|
}
|