Compare commits
1 Commits
hw3
...
hw3-backup
Author | SHA1 | Date | |
---|---|---|---|
f2ee03502d
|
@@ -1,3 +1,8 @@
|
||||
import controller.PhotoAlbumController;
|
||||
import model.PhotoAlbumModel;
|
||||
import view.PhotoAlbumView;
|
||||
|
||||
|
||||
/**
|
||||
* Photo Album Manager application entry point.
|
||||
* <p>
|
||||
|
@@ -1,3 +1,12 @@
|
||||
package controller;
|
||||
|
||||
import model.Photo;
|
||||
import model.PhotoAlbumModel;
|
||||
import strategy.SortByDate;
|
||||
import strategy.SortByName;
|
||||
import strategy.SortBySize;
|
||||
import view.PhotoAlbumView;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import java.io.File;
|
@@ -1,3 +1,7 @@
|
||||
package iterator;
|
||||
|
||||
import model.Photo;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
@@ -1,3 +1,7 @@
|
||||
package iterator;
|
||||
|
||||
import model.Photo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
@@ -1,3 +1,5 @@
|
||||
package model;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
@@ -1,3 +1,9 @@
|
||||
package model;
|
||||
|
||||
import strategy.SortingStrategy;
|
||||
import iterator.AlbumIterator;
|
||||
import iterator.PhotoIterator;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -53,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);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
@@ -1,3 +1,7 @@
|
||||
package strategy;
|
||||
|
||||
import model.Photo;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@@ -1,3 +1,7 @@
|
||||
package strategy;
|
||||
|
||||
import model.Photo;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@@ -1,3 +1,7 @@
|
||||
package strategy;
|
||||
|
||||
import model.Photo;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@@ -1,3 +1,5 @@
|
||||
package strategy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
@@ -1,3 +1,9 @@
|
||||
package view;
|
||||
|
||||
import controller.PhotoAlbumController;
|
||||
import model.Photo;
|
||||
import model.PhotoAlbumModel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.HashMap;
|
Reference in New Issue
Block a user