Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CarlosCorderoSaavedra/1574681c8bc3f0c5cfb3 to your computer and use it in GitHub Desktop.
Save CarlosCorderoSaavedra/1574681c8bc3f0c5cfb3 to your computer and use it in GitHub Desktop.
import java.util.ArrayList;
public class ListOfPictures
{
public static void main(String[] args)
{
ArrayList<Picture> gallery = new ArrayList<Picture>();
gallery.add(new Picture("degas1.jpg"));
gallery.add(new Picture("gaugin1.jpg"));
gallery.add(new Picture("monet1.jpg"));
gallery.add(new Picture("monet2.jpg"));
gallery.add(new Picture("renoir1.jpg"));
ArrayList<Picture> matches = new ArrayList<Picture>();
for (Picture pic : gallery){
if(pic.getHeight() > pic.getWidth()){
matches.add(pic);
}
}
int rightmostX = 0;
for (Picture pic : matches)
{
pic.translate(rightmostX + 10, 0);
rightmostX = pic.getMaxX();
pic.draw();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment