public static void main(String[] args) { // TODO Auto-generated method stub Multiplication m = new Multiplication(); // m.mul(2, 3); System.out.println(m.mul(2, 3)); }
public static Equation parse(String input) { if (input == null) { throw new NullPointerException("The parameter [input] is null."); } String[] sides = input.replace('(', ' ').replace(')', ' ').trim().split("="); if (sides.length < 2) { return null; } Derivation der = Derivation.parse(sides[0]); Coefficient c = Coefficient.parse(sides[1]); if (c != null) { return new Equation(der, c); } Variable v = Variable.parse(sides[1]); if (v != null) { return new Equation(der, v); } Multiplication mul = Multiplication.parse(sides[1]); if (mul != null) { return new Equation(der, mul); } Addition add = Addition.parse(sides[1]); if (add != null) { return new Equation(der, add); } return null; }
@Override public PersistentAbsQuantity mul( final PersistentAbsQuantity factor1, final PersistentAbsQuantity factor2) throws model.NotComputableException, PersistenceException { final PersistentMultiplication multi = Multiplication.createMultiplication(); multi.setArg1(factor1); multi.setArg2(factor2); multi.calculate(); return multi.getResultt(); }
public static void main(String args[]) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter two nos: \n"); int a = Integer.parseInt(br.readLine()); int b = Integer.parseInt(br.readLine()); int ans = Multiplication.multiply(a, b); System.out.println("My ans: " + ans); }
@Test public void tableUpToLimit() { assertEquals( "0 x 0 = 0\n" + "0 x 1 = 0\n" + "0 x 2 = 0\n" + "0 x 3 = 0\n" + "1 x 0 = 0\n" + "1 x 1 = 1\n" + "1 x 2 = 2\n" + "1 x 3 = 3\n" + "2 x 0 = 0\n" + "2 x 1 = 2\n" + "2 x 2 = 4\n" + "2 x 3 = 6\n" + "3 x 0 = 0\n" + "3 x 1 = 3\n" + "3 x 2 = 6\n" + "3 x 3 = 9\n", Multiplication.table(3)); }
@Test public void tableUpToZero() { assertEquals("0 x 0 = 0\n", Multiplication.table(0)); }
@Test public void tableUpToOne() { assertEquals( "0 x 0 = 0\n" + "0 x 1 = 0\n" + "1 x 0 = 0\n" + "1 x 1 = 1\n", Multiplication.table(1)); }