Results 1 to 5 of 5
  1. #1
    Track13 is offline Member
    Join Date
    Nov 2012
    Posts
    11
    Rep Power
    0

    Default I need a nudge in the right direction for my method

    I am almost done with my program. I am just stuck on my explore method.
    The explore method is to add a new picture.
    -create a picture whose height is the max of the heights
    -width is the sum of the widths of the stored pictures
    -pictures in the Album should be copied into a new picture

    Java Code:
    public class Album
    {
       private int nPictsInAlbum;
       private int capacity;
       private Picture[] pictArray;
       
      public Album(int capacityParam )
      {
        capacity = capacityParam; 
        this.pictArray = new Picture[capacity];
        this.nPictsInAlbum = 0;
        //System.out.println("Album ( " + capacityParam + " ) constructor called.");
      }
      
      public boolean addPicture( Picture thePicture )
      {
        if(this.nPictsInAlbum >= this.capacity)
        {
          return false;
        }
        else 
        { 
        this.pictArray[nPictsInAlbum] = thePicture;
        this.nPictsInAlbum = nPictsInAlbum + 1;
        return true;
        }
        //System.out.println("addPicture( thePicture ) called.  The Picture object param. printed as a String is");
        //System.out.println( thePicture );
      } 
      
      public boolean addPicture( Picture thePicture, int where )
      {
        int index = nPictsInAlbum;
        pictArray[index] = pictArray[index-1];
          
        while( index > where )
        {
          pictArray[where] = thePicture;
          nPictsInAlbum ++;
        }
        //System.out.println("addPicture( thePicture , " + where + " ) called.  The Picture object param. 
        //                                 printed as a String is");
        //System.out.println( thePicture );
        return true;
      }
    
     I am stuck on this method --->
     public void explore()
      {
        int width = this.getWidth();
        int height = this.getHeight();
        int maxHeight;
        
        //System.out.println("explore called");
      }
    }

  2. #2
    ray0406 is offline Member
    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    Default Re: I need a nudge in the right direction for my method

    If you have the same book I do, there is the chapter about copying flowers and moving them that teaches us how to make a collage, and that should probably help with the explore method.

  3. #3
    Track13 is offline Member
    Join Date
    Nov 2012
    Posts
    11
    Rep Power
    0

    Default Re: I need a nudge in the right direction for my method

    Well it is helping a little bit. I already know I have to declare a loop to loop through the pictures to gather the height and the width. Now I am trying to figure out how to not overlap the pictures.

  4. #4
    ray0406 is offline Member
    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    Default Re: I need a nudge in the right direction for my method

    that, should be pretty easy, just get the x width of the last picture and move the next picture x width to the left.

  5. #5
    ray0406 is offline Member
    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    Default Re: I need a nudge in the right direction for my method

    quick question, how do we use the album tester to test the project?

Similar Threads

  1. GetComponent using Direction
    By blug in forum AWT / Swing
    Replies: 1
    Last Post: 10-23-2012, 07:55 PM
  2. Need direction please
    By kprofgold in forum New To Java
    Replies: 3
    Last Post: 01-06-2012, 06:45 AM
  3. Need Direction
    By johnjacob in forum New To Java
    Replies: 10
    Last Post: 06-16-2011, 07:45 AM
  4. Looking for direction...
    By ewomack in forum New To Java
    Replies: 4
    Last Post: 09-14-2009, 12:00 AM
  5. [SOLVED] Need direction...
    By hotice1027 in forum New To Java
    Replies: 5
    Last Post: 11-28-2008, 10:03 AM

Tags for this Thread

Posting Permissions

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