Skip to content

Character and Book Reader #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
sout adding for debugging
  • Loading branch information
ToofastTurnip committed Mar 12, 2018
commit d4646759b5f2293b89ab5a19e8c467feb4bca41c
14 changes: 7 additions & 7 deletions src/main/java/io/zipcoder/WC.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Scanner;

public class WC {

private Iterator<String> si;
private String file;// = WC.class.getResource("someTextFile.txt").getFile();
private String entireFile;
private String entireFile;// = WC.class.getResource("someTextFile.txt").getFile();

// Nullary constructor for testing
public WC(){}

public WC(String fileName) {
try {
// NOTED OUT TEMPORARILY BECAUSE AM DINGUS
//this.si = new Scanner(new FileReader(fileName));
this.entireFile = new Scanner(new File(WC.class.getResource("/someTextFile.txt").getFile())).useDelimiter("\\A").next();
} catch (FileNotFoundException e) {
Expand All @@ -26,16 +26,16 @@ public WC(String fileName) {
}
}

// NOTED OUT BECAUSE STRING TESTS ARE FOR WEE BABIES
// NOTED OUT BECAUSE STRING ITERATOR IS BLEH
// public WC(Iterator<String> si) {
// this.si = si;
// }

public void logic() {
System.out.println(entireFile);
file = entireFile;
HashMap<String, Integer> wordsAndAmounts = new HashMap<String, Integer>();
String[] arrayOfWords = file.split(" ");
String[] arrayOfWords = entireFile.split(" ");
System.out.println(Arrays.toString(arrayOfWords));
for (int j = 0; j < arrayOfWords.length; j++) {
String currentWord = arrayOfWords[j];
currentWord.toLowerCase();
Expand All @@ -48,7 +48,7 @@ public void logic() {
}
}
// Print out all words next to how many times they appear
for (String name: wordsAndAmounts.keySet()){
for (String name : wordsAndAmounts.keySet()){
String value = wordsAndAmounts.get(name).toString();
System.out.println(name + " " + value);
}
Expand Down
1 change: 1 addition & 0 deletions src/test/java/io/zipcoder/WCTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

public class WCTest {

// What am I testing
@Test
public void printWC() {
WC wc = new WC(WC.class.getResource("/someTextFile.txt").getFile());
Expand Down