Open GunterOdimm opened 5 years ago
자식클래스 QNAArticle
public class QNAArticle extends Article {
private String answer;
public String getAnswer() {
return answer;
}
public void setAnswer(String answer) {
this.answer = answer;
}
@Override
public String toString() {
return "질문/답변 [글번호=" + getNum() + ",제목 =" + getTitle() + ",답변 =" + answer + "]";
}
}
자식 클래스 FileArticle
public class FileArticle extends Article {
private String FileName;
public String getFileName() {
return FileName;
}
public void setFileName(String fileName) {
FileName = fileName;
}
@Override
public String toString() {
return "자료실 [번호 =" + getNum() + ",제목 = " + getTitle() + ", 첨부파일 =" + FileName + "]";
}
}
메인 LibrarySearch 클래스
public class LibrarySearch {
public static void main(String[] args) {
FileArticle FileArticle1 = new FileArticle();
FileArticle1.setNum(1);
FileArticle1.setTitle("첫번째 자료입니다");
FileArticle1.setFileName("자바.ppt");
System.out.println(FileArticle1.toString());
System.out.println("----------------------------------");
QNAArticle QNA = new QNAArticle();
QNA.setNum(1);
QNA.setTitle("첫 번째 질문입니다");
QNA.setAnswer("첫 번째 답변입니다");
System.out.println(QNA.toString());
}
}
최상단 부모 클래스