We have homework due tomorrow, and it's a three person group. I don't understand the slightest bit about arrays, but I've been trying - now the code just looks messy. Just with the things that say ------------------Tierra------------------, can you all help me? The book is useless and I'm just frustrated now, I don't know what to do.
//*************************************************************************
//Purpose: Processing text files and ArrayLists
//
//Author: Chloe Kimble
//Date: 10/30/2015
//Course: CS1301
//
//*************************************************************************
import java.util.*;
import java.io.*;
public class MyTokens9 {
ArrayList <String> allLines = new ArrayList<>();
ArrayList <String> allTokens = new ArrayList<>();
ArrayList <String> alphA = new ArrayList<>();
ArrayList <String> others = new ArrayList<>();
ArrayList <Integer> numeric = new ArrayList<>();
String longestToken;
int numberOfLines; //done
int numberOfTokens; //done
int numberOfCharacters;
int numberOfLetters;
int numberOfDigits;
int numberOfAlphaTokens;
int numberOfNumericValues;
int numberOfOtherTokens;
double averageOfNumericValue;
//Reads all data from input file and stores each line in an
//entry of the allLines ArrayList.
//**********************Nicholas***************************
public MyTokens9 (scan Scanner){
numberOfLines = 0;
while(scan.hasNext()){
allLines.add(scan.nextLine());
numberOfLines++;
}
System.out.print(allLines);
}
//Scans each entry (a line of text –token-) of allLines ArrayList
//and stores alphabetic in alpha ArrayList, Integers in numeric ArrayList,
//and all others in others Arraylist. Computes number of lines,
//number of tokens, number of alphabetic tokens, numeric values,
//and others. Also, find the longest token in the file.
//*********************Nicholas***************************
public void processAllTokens(){
String alphaPattern = "[A-Za-z]*";
String numericPattern = "[0-9]*";
String line;
String token;
for (int i =0; i < allLines.size(); i++){
line = allLines.get(i);
Scanner scanLine = new Scanner (line);
scanLine.useDelimiter ("[ .,:;!?]+");
while (scanLine.hasNext()){
token = scanLine.next();
allTokens.add(token);
numberOfTokens++; //????????????????????????????????????????
if (token.matches(alphaPattern))
alpha.add(token);
else if (token.matches (numericPattern))
numeric.add(Integer.parseInt(token));
else
others.add (token);
}//end of while
}//end of for
}//end of method
//Processes allTokens ArrayList and count numbers of characters,
//letters, digits, alpha tokens, and numeric values.
//*********************Nicholas***************************
//*************not done***********************************
public void processCharacters(){
String token;
for(int i = 0; i < allTokens.size; i++){
String alphaPattern = "[A-Za-z]*$";
String numericPattern = "[0-9]*$";
if (token.matches (alphaPattern)){
numberOfLetters ++;
}
else if (token.matches (numericPattern)){
numberOfDigits ++;
}
else if (token.
numberOfAlphaTokens ++;
}//end of inside for
}//end of outside for
}//end of method
//Displays the contents of a String ArrayList
//-----------------Tierra--------------------
public void displayStringArrayList(ArrayList<String> allLines, allTokens, alphA, others ){
System.out.println ("\n\tString ArrayList");
for (int i = 0; i < list.size(); i++){
System.out.println (list.get(i));
}
}
//Displays the contents of an Integer ArrayList
//-----------------Tierra--------------------
public void displayIntegerArrayList(ArrayList<Integer> numeric){
System.out.println ("\n\tInteger ArrayList");
for (int i = 0; i < list.size(); i++){
System.out.println (list.get(i));
}
}
//Computes the numeric average
//-----------------Tierra--------------------
public void average(ArrayList<Integer>){
public double average (int [] numeric){
return (double) sum (numeric) / list.length;
}
//Invokes displayStringArrayList to print AllLines, allTokens,
//alpha, and others ArrayLists.
//Also, it invokes displayIntegerArrayList to print the numeric ArrayList.
//-----------------Tierra--------------------
public void displayAllLists(){
public void displayStringArrayList(ArrayList<String> allLines, allTokens, alphA, others ){
System.out.println ("\n\tString ArrayList");
for (int i = 0; i < list.size(); i++){
System.out.println (list.get(i));
}
}
public void displayIntegerArrayList(ArrayList<Integer> numeric){
System.out.println ("\n\tInteger ArrayList");
for (int i = 0; i < list.size(); i++){
System.out.println (list.get(i));
}
}
}
//Returns a string with the values of the instance variables
//with the exception of the ArrayLists.
public String toString(){
}
}