写第一轮考核作业,西瓜店的思考
首先是类的构建,遗忘
Booth a=new Booth(100010,"aaa",22,true);
Booth b=new Booth(100020,"bbb",23,false);
Booth c=new Booth(100030,"ccc",24,false);
接下来是数组构造,遗忘
Booth[] booths=new Booth[3];
然后就是类的方法构造有知识性遗忘
public Booth(long id,String name,int total,boolean isClosed) {
this.id = id;
this.name = name;
this.total = total;
this.isClosed = isClosed;
}
不要忘了下面这些
this.id = id;
this.name = name;
this.total = total;
this.isClosed = isClosed;
然后没必要给抽象类赋值
然后就是toString(),是类似于getxx(),的得到值的,而不是输出值的
@Override
public String toString() {
System.out.println();
return "Booth{" +
"id=" + id +
", name='" + name + '\'' +
", total=" + total +
", isClosed=" + isClosed +
'}';
应该把toString()放在sout里打印出来
System.out.println(i.toString());