category.java
来自「这是我最近自己做的一个小JAVA程序,请各位多多指教.谢谢了.」· Java 代码 · 共 51 行
JAVA
51 行
import java.util.*;
public class Category{
private String name;
private Category parentCategory;
private Set<Category> childCategories=new HashSet<Category>();
public Category(String name,Category parentCategory, Set<Category> childCategories) {
this.name = name;
this.parentCategory = parentCategory;
this.childCategories = childCategories;
}
public Category() {}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public Category getParentCategory() {
return parentCategory;
}
public void setParentCategory(Category parentCategory) {
this.parentCategory = parentCategory;
}
public Set getChildCategories() {
return childCategories;
}
public void setChildCategories(Set<Category> childCategories) {
this.childCategories = childCategories;
}
public void addChildCategory(Category category) {
if (category == null)
throw new IllegalArgumentException("Can't add a null Category as child.");
childCategories.add(category);
}
public String toString() {
return name;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?