parent
81c5665449
commit
8ea4f36ebc
@ -0,0 +1,83 @@
|
||||
package test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Poetry {
|
||||
// 古诗id,自动递增填充
|
||||
private static Integer poetryCount = 0;
|
||||
private String AId;
|
||||
// 古诗名
|
||||
private String name;
|
||||
//所属诗人(朝代-人名)
|
||||
private Poet poet;
|
||||
//古诗内容
|
||||
private ArrayList<String> content;
|
||||
//是否已经阅读过
|
||||
private Boolean learned = false;
|
||||
|
||||
public Poetry(Poet poet,String name, ArrayList<String> content){
|
||||
this.poet = poet;
|
||||
this.name = name;
|
||||
this.content = content;
|
||||
poetryCount += 1;
|
||||
this.AId = poetryCount.toString();
|
||||
}
|
||||
|
||||
public Poetry(ArrayList<String> content) {
|
||||
this.content = content;
|
||||
poetryCount += 1;
|
||||
this.AId = poetryCount.toString();
|
||||
}
|
||||
|
||||
public Poet getPoet() {
|
||||
return poet;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ArrayList<String> getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public Boolean getLearned() {
|
||||
return learned;
|
||||
}
|
||||
public String getAId(){
|
||||
return AId;
|
||||
}
|
||||
public void setLearned(Boolean learned){
|
||||
this.learned=learned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer contentString = new StringBuffer();
|
||||
for(String i: this.content){
|
||||
contentString.append(i + '\n');
|
||||
}
|
||||
return this.name + '\n' +
|
||||
"(" + this.poet.getDynasty() + ")" + this.poet.getName() + '\n' +
|
||||
contentString + '\n';
|
||||
}
|
||||
|
||||
public void showContents(){
|
||||
StringBuffer contentString = new StringBuffer();
|
||||
for(String i: this.content){
|
||||
contentString.append(i + '\n');
|
||||
}
|
||||
System.out.println(contentString + "\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Poetry poetry = (Poetry) o;
|
||||
return Objects.equals(AId, poetry.AId) && Objects.equals(name, poetry.name) && Objects.equals(poet, poetry.poet) && Objects.equals(content, poetry.content) && Objects.equals(learned, poetry.learned);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in new issue