Results 1 to 3 of 3

Thread: Boolean Help Needed

  1. #1
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Boolean Help Needed

    I'm having issues with these two parts of my code.

    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):

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

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

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

  2. #2
    Join Date
    May 2009
    Location
    Bordeaux - FRANCE
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

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

  3. #3
    Join Date
    Aug 2009
    Location
    Egypt
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up I'm good with boolean methods

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •