MCPcopy Create free account
hub / github.com/careercup/ctci / numberOfFiles

Method numberOfFiles

java/Chapter 8/Question8_9/Directory.java:25–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23 }
24
25 public int numberOfFiles() {
26 int count = 0;
27 for (Entry e : contents) {
28 if (e instanceof Directory) {
29 count++; // Directory counts as a file
30 Directory d = (Directory) e;
31 count += d.numberOfFiles();
32 } else if (e instanceof File) {
33 count++;
34 }
35 }
36 return count;
37 }
38
39 public boolean deleteEntry(Entry entry) {
40 return contents.remove(entry);

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected