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/0ded541b93f31fb377af to your computer and use it in GitHub Desktop.
Save CarlosCorderoSaavedra/0ded541b93f31fb377af 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"));
// Your code here
int count = 0;
for(Picture pic : gallery){
if(pic.getHeight() > pic.getWidth()){
count++;
}
}
System.out.println("Pictures with portrait orientation: " + count);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment