-
Notifications
You must be signed in to change notification settings - Fork 1
/
Export.java
74 lines (60 loc) · 2.6 KB
/
Export.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
// import java.util.Scanner;
import java.io.PrintWriter;
class Export {
/**
* Prints out all of the plagiarised haikus and lines
*
* @param flaggedContent the ArrayList of flagged content
* @param printWriter used to print to .csv file
*/
public static void printFlaggedContent(ArrayList<String> flaggedContent, PrintWriter printWriter) {
for(String line: flaggedContent){
printWriter.println(line);
}
}
/**
* @see PlagiarismChecker for explanation of why we couldn't ask user to overwrite
*/
// public static int askOverwrite(File[] resultsFiles){
// Scanner reader = new Scanner(System.in);
// System.out.println("Do you wish to overwrite the latest results.csv file? (y/n): ");
// String overwriteChoice = reader.nextLine();
// reader.close();
// if (!overwriteChoice.equals("y") || !overwriteChoice.equals("n")) {
// System.out.println("Invalid file name.");
// askOverwrite(resultsFiles);
// }
// if(overwriteChoice == "y"){
// return resultsFiles.length - 1;
// }
// return resultsFiles.length;
// }
/**
* Display results in .csv file
*
* @param submissionFile the name of the selected submission file
* @param flaggedContent a 2D ArrayList of flagged Haikus
* @param flaggedLibraryFiles an ArrayList of the filenames of library files with plagiarized content
* @param printWriter used to write to .csv
* @throws IOException
*/
public static void exportResults(File submissionFile, ArrayList<ArrayList<String>> flaggedContent, ArrayList<String> flaggedLibraryFiles, PrintWriter printWriter) throws IOException {
// Prints the user-inputted submissions file name
printWriter.println("Submission File name: " + submissionFile.getName());
// All of printWriter.println() is to improve readability of the results.csv file
printWriter.println();
// Prints out the plagiarised haiku from the submissions file
// and the name of the library file that got plagiarised
for(int i = 0; i < flaggedContent.size() - 1; i++){
printWriter.println("Flagged Content: ");
printFlaggedContent(flaggedContent.get(i), printWriter);
printWriter.println();
printWriter.println("Located in library file: " + flaggedLibraryFiles.get(i));
printWriter.println();
}
printWriter.close();
}
}