PDA

View Full Version : Boolean Help Needed



Kiri
03-24-2009, 04:09 AM
I'm having issues with these two parts of my code. :confused:

I already declared a string ArrayList called "list", and I have another class called Magazine which adds magazines to the list. This class I'm having issues with is called MagazineList. I'm not very good with boolean methods... :(

Problem #1 (adding from another MagazineList to the list):


public boolean addAll(MagazineList magazines)
{
if (list == magazines) {
return false;
}
else {
list.addAll(magazines);
}
return true;
}



Problem #2 (adding to MagazineList from text file):



public boolean addAll(String filename)
{
Scanner in = ResourceUtil.openFileScanner(filename);
if (in == null) {
System.out.println("Bad filename " + filename);
return false;
}
String line = source.nextLine();
while (!line.equals("")) {
list.add(Magazine(source));
}
in.close();
}

wmahann
05-13-2009, 01:16 PM
Hi Kiri,
Excuse me for my english because i'm french.
I found an error on problem #2.
Please try this :

String line = source.nextLine();
while (!line.equals("")) {
list.add(Magazine(source));
line = source.nextLine();
}

HosHos
08-13-2009, 11:18 AM
i Think you don't have a problem with the return .
but i don't understand what do you want to do.
plz re-explain it and i hope i will be more helpfull.:)