Explorar el Código

inital commit

master
theycallmemac hace 3 años
padre
commit
4d5ebba645
Se han modificado 3 ficheros con 32 adiciones y 0 borrados
  1. +10
    -0
      Factorial.java
  2. +17
    -0
      makefile
  3. +5
    -0
      tests/javaTest.sh

+ 10
- 0
Factorial.java Ver fichero

@@ -0,0 +1,10 @@
class Factorial {
public static void main(String args[]){
int factorial = 1;
int number = Integer.parseInt(args[0]);
for(int i = 1; i <= number; i++) {
factorial = factorial * i;
}
System.out.println("Factorial of " + number + " is: " + factorial);
}
}

+ 17
- 0
makefile Ver fichero

@@ -0,0 +1,17 @@

targets = Factorial.class

build: $(targets)
@true

%.class: %.java
javac $<

test:
$(MAKE) build
for script in tests/*.sh; do sh $$script && echo "$$script passed\n" || echo -e "$$script failed\n" && exit 1; done

clean:
rm -fv $(targets)



+ 5
- 0
tests/javaTest.sh Ver fichero

@@ -0,0 +1,5 @@
#!/bin/sh

set -e

java Factorial 5 | grep -q -w 120

Cargando…
Cancelar
Guardar