mirror of
https://github.com/This-weiyuqing/javaAutoScore.git
synced 2026-10-18 03:03:42 +08:00
update
Added steps to write to score file.
This commit is contained in:
1 parent
1347614e57
commit
7c7166c6b7
4 files changed
+59
-24
No files matched your search
+34
-11
@@ -1,15 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2020 魏遇卿 All Rights Reserved.
|
||||
* FileName: a.java
|
||||
* @author: 魏遇卿@date: 2020/6/19 下午8:02@version: 1.0
|
||||
* E-mail:358614401@qq.com
|
||||
* Code with UTF-8
|
||||
*/
|
||||
package autoScore;
|
||||
|
||||
public class score {
|
||||
public static int getScore (int score,char choose,char anwser){
|
||||
if (choose ==anwser ) {
|
||||
score++;
|
||||
return score;
|
||||
}else {
|
||||
return score;
|
||||
}
|
||||
}
|
||||
public static void scoreToTxt(/*String name*,*/int score){
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class score {
|
||||
public static int getScore(int score, char choose, char anwser) {
|
||||
if (choose == anwser) {
|
||||
score++;
|
||||
return score;
|
||||
} else {
|
||||
return score;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void scoreToTxt(/*String name*,*/int score) throws IOException {
|
||||
File writename = new File("D:\\WindowsCToD\\fire\\GeneticsMultipleChoice\\Score\\output.txt"); // 相对路径,如果没有则要建立一个新的output。txt文件
|
||||
writename.createNewFile();
|
||||
BufferedWriter out = new BufferedWriter(new FileWriter(writename));
|
||||
out.write(/*name+*/"score:" + score + "\r\n"); // \r\n即为换行
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
|
||||
/*public static void main(String[] args) throws IOException {
|
||||
scoreToTxt(5);
|
||||
}*/
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user