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();
}
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();
}