Box と PackageBox という名前の不完全なテスト クラスがあります。Box は、Box を拡張することになっている Builder パターンと PackageBox を使用します。
ここにいくつかのコードがあります
package console.app.model;
public class Box {
private String name = "";
private int weight = 0;
private int width = 0;
private int height = 0;
// Box instance for comparison on method equals().
private static Box comparisonBox;
public static class Builder {
private String name = "";
private int weight = 0;
private int width = 0;
private int height = 0;
public Builder(String name) {
this.name = name;
}
public Builder weight(int weight) {
this.weight = weight;
return this;
}
public Builder width(int width) {
this.width = width;
return this;
}
public Builder height(int height) {
this.height = height;
return this;
}
public Box build() {
return new Box(this);
}
}
private Box(Builder builder) {
name = builder.name;
weight = builder.weight;
width = builder.width;
height = builder.height;
}
// Setters and getters, etc.
}
Box を PackageBox に拡張するにはどうすればよいですか? ありがとうございます。何か問題がある場合は、私に教えていただくか、Box クラスで置き換えるものを教えてください。