組合模式 合成模式 COMPOSITE 結構型 設計模式(十一)
阿新 • • 發佈:2019-02-01
package composite; public class Client { public static void del(FileSystem fileSystem){ fileSystem.delete(); System.out.println("DELETED"); System.out.println(); } public static void main(String[] args){ Folder folder = new Folder(); Folder folder1= new Folder(); Folder folder2 = new Folder(); Folder folder3 = new Folder(); File file1 = new File(); File file2 = new File(); File file3 = new File(); File file4 = new File(); folder.add(file1); folder.add(folder1); folder.add(folder2); folder1.add(file2); folder1.add(folder3); folder3.add(file4); folder2.add(file3); del(folder); del(folder1); del(file2); del(folder2); } }