浏览代码

inital commit

master
theycallmemac 3 年前
父节点
当前提交
4d5ebba645
共有 3 个文件被更改,包括 32 次插入0 次删除
  1. +10
    -0
      Factorial.java
  2. +17
    -0
      makefile
  3. +5
    -0
      tests/javaTest.sh

+ 10
- 0
Factorial.java 查看文件

@@ -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 查看文件

@@ -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 查看文件

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

set -e

java Factorial 5 | grep -q -w 120

正在加载...
取消
保存