Sync Composite to Java 25: H6 file labels, fix console output typo, README mapping

This commit is contained in:
2026-06-24 14:30:27 +05:30
parent 4091345b20
commit ad6a65a95d
6 changed files with 77 additions and 76 deletions

View File

@@ -1,25 +1,18 @@
package composite;
/**
* Leaf — a single file. It has no children.
* getSize() returns its own size. print() shows its name.
*
* Notice: the File has no knowledge of directories or nesting.
* It just knows its own name and size.
* Leaf — a single file with no children.
* getSize() returns its own bytes. print() outputs a single line.
* No knowledge of directories or nesting exists in this class.
*/
public class File implements FileSystemItem {
private final String name;
private final long size;
public File(String name, long sizeBytes) {
this.name = name;
this.size = sizeBytes;
}
@Override public String getName() { return name; }
@Override public long getSize() { return size; }
@Override
public void print(String indent) {
System.out.printf("%s[FILE] %s (%,d bytes)%n", indent, name, size);