Writing a program that interprets a line from a text file.
Wondering if I should be naming the local variables in method 'parseWordData' something likescannedWord
as oppposed to word
, because word
is already a class field.
as long as I am declaring a new variable instead of reassigning the old one, everything should be fine...right?
public class WordData {
private String word;
private int index;
private LinkedList<Integer> list;
private boolean pathFound;
public WordData(String word, int index, LinkedList<Integer> list, boolean pathFound) {
this.word = word;
this.index = index;
this.list = list;
this.pathFound = pathFound;
}
public WordData parseWordData(String line){
Scanner scan = new Scanner(line);
int index = scan.nextInt();
String word = scan.next();
//precond and subGoal
LinkedList<Integer> list = new LinkedList<Integer>();
while(scan.hasNextInt()){
//add to LinkedList
}
return new WordData(word, index, list, false)
}
dont worry about the logic, i just want to know if naming things like this will be confusing or is taboo in java