-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlbum.java
46 lines (39 loc) · 1.18 KB
/
Album.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.util.Iterator;
class Album {
Pagina[] paginas;
//int next = 0;
int currentPage = 0;
Album(int width, int height, int numPages){
paginas = new Pagina[numPages];
for (int i = 0; i < paginas.length; i++)
//podemos alterar fundo pre-definido da página
paginas[i] = new Pagina(width, height, new ColorImage("blue_leafs.bmp"));
}
//permite colocar uma foto na página à escolha
void addImgToPage(ColorImage img, int pageNb){
paginas[pageNb].addPhoto(new Foto(img, "", ""));
}
void displayCurrentPage(){
if (paginas[currentPage] == null)
throw new NullPointerException("paginas is null!");
System.out.println("Current page is " + currentPage);
paginas[currentPage].displayPhotos();
}
void nextPage(){
if (currentPage == paginas.length - 1)
throw new IllegalStateException("Already at the last page!");
currentPage++;
displayCurrentPage();
}
void previousPage(){
if (currentPage == 0)
throw new IllegalStateException("Already at the first page!");
currentPage--;
displayCurrentPage();
}
void swapPage(int a, int b){
Pagina tmp = paginas[a];
paginas[a] = paginas[b];
paginas[b] = tmp;
}
}