I'm creating a new class called album which is supposed to make an album and show pictures with caption. so.. Ok my problem is the methods section... i need help to set the array in the picture album and set the captions too can any one please help me out ? the methods part is a head ache

/** this is a class that represents an album of images with their associated captions.
  */
public class Album {

/////////////////////////// Fields //////////////////////////////

/**
  * The file name associated with the Album class
  */
   private String albumName;

/**
 * The double array for picture Image
 */
   private Picture[] picArray;

/**
 * an Array of type String to hold up captions corresponding to each picture in the pictureImageArray.
 */
   private String[] pictureCaptionArray;

 ////////////////////////// Constructors /////////////////////////

/**
  * constructor with no argument.
  */
   public Album()  {
 }

/**
 * constructor with one argument
 */
   public Album(String MySummerVacations) {
    this.albumName = MySummerVacations;
 }

////////////////////////// Methods /////////////////////////////
/**
 * sets the album's name
 */
   public void setalbumName(String MySummerVacations)
  { this.albumName = MySummerVacations; }

/**
 * returns the album's name string.
 */
   public String getalbumName()
    { return albumName; }

  /**
   * sets the array of the pictures in the album.
   */
   public void setPictures(Picture[] picArray) 
   { this.albumName setPictures; }

   public void setCaptions(String[] captionsArray) 
   { this.captions = captions; }

   public void showAlbum() 
   { this.Pictureshow(); }

Your solution is not very flexible. I would replace Array with ArrayList as in doing so I do not have to check for number of elements to set array size where to store images with their captions. Something like this

/**
 * @(#)AlbumImage.java
 *
 *
 * @author 
 * @version 1.00 2009/4/20
 */

import java.awt.Image;

public class AlbumImage {
	
	private Image albumImage;
	private String imageCaption;

    public AlbumImage() {}
    
    public AlbumImage(Image img, String str){
    	setAlbumImage(img);
    	setImageCaption(str);
    }
    
    private void setAlbumImage(Image img){albumImage = img;}
    public Image getAlbumImage(){ return albumImage;}
    
    private void setImageCaption(String str){ imageCaption = str;}
    public String getImageCaption(){ return imageCaption;}
    
    public AlbumImage getImage(){
    	return new AlbumImage(getAlbumImage(), getImageCaption());
    }
}
/**
 * @(#)Album.java
 *
 *
 * @author 
 * @version 1.00 2009/4/20
 */
import java.awt.Image;
import java.util.ArrayList;

public class Album {
	
	private String albumName;
	private ArrayList<AlbumImage> albumImage;

    public Album() {
    }
    
    public Album(String str){
    	setAlbumName(str);
    }
    
    
    private void setAlbumName(String str){ albumName = str;}
    public String getAlbumName(){ return albumName;}
    
    public void addAlbumImage(Image img, String str){
    	albumImage.add(new AlbumImage(img, str));
    }
    
    public AlbumImage getAlbumImage(int i){
    	return albumImage.get(i);
    }
}

As for other methods that can be used with these two classes, it does depends on the specification of your project/assignment.

PS: setAlbumImage() method does need better implementation to handle any possible exceptions

thanks, I found the solution to my problem, thank you so much for the help this site is really useful

One would be nice if you shared your solution, it may help others. Secondly if the problems is solved you should mark thread as solved. After last post there is a blue link saying Mark as Solved, just click it and all is done

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.