Compare commits
1 Commits
master
...
hw3-backup
Author | SHA1 | Date | |
---|---|---|---|
f2ee03502d |
@ -59,18 +59,14 @@ public class PhotoAlbumModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a photo from the album by name.
|
||||
* If the deleted photo is the current photo or the album is empty,
|
||||
* the iterator is reset.
|
||||
* Deletes a photo from the album by name (if it exists).
|
||||
* Resets the iterator and notifies the listeners.
|
||||
*
|
||||
* @param name the name of the photo to delete
|
||||
*/
|
||||
public void deletePhoto(String name) {
|
||||
Photo currentPhoto = iterator.current();
|
||||
photos.removeIf(photo -> photo.name().equals(name));
|
||||
if (photos.isEmpty() || (currentPhoto != null && currentPhoto.name().equals(name))) {
|
||||
iterator = new PhotoIterator(photos);
|
||||
}
|
||||
iterator = new PhotoIterator(photos);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user