001 /* PAVLOV -- Multiple Choice Study System 002 * Copyright (C) 2000 - 2004 T.J. Willis 003 * 004 * This program is free software; you can redistribute it and/or 005 * modify it under the terms of the GNU General Public License 006 * as published by the Free Software Foundation; either version 2 007 * of the License, or (at your option) any later version. 008 * 009 * This program is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 012 * GNU General Public License for more details. 013 * 014 * You should have received a copy of the GNU General Public License 015 * along with this program; if not, write to the Free Software 016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. 017 * 018 * $Header: /cvsroot/pavlov/net/sourceforge/pavlov/library/AbstractChapter.java,v 1.6 2004/06/29 02:51:16 tj_willis Exp $ 019 */ 020 package net.sourceforge.pavlov.library; 021 022 import java.io.IOException; 023 import java.io.Writer; 024 import java.util.Collection; 025 import org.apache.log4j.*; 026 /** 027 * An interface to be implemented by classes that can act as Pavlov chapters. 028 * As of Pavlov 1.0, the only implementation is Chapter, which reads a chapter 029 * from a given book in an XML file. However, there's no reason that an implementation 030 * couldn't be written to generate its questions programmatically, 031 * i.e., an arithmetic chapter "Addition" that 032 * generates questions algorithmically from the question ID. 033 * 034 * @author <a href="mailto:tj_willis@users.sourceforge.net"></a> 035 * @version 1.0 036 * @has 1 Has 1..n net.sourceforge.pavlov.library.Question 037 */ 038 public interface AbstractChapter extends Comparable { 039 040 /** 041 * Returns who wrote or maintains this chapter. 042 * @return a <code>String</code> value 043 */ 044 String getAuthor(); 045 046 /** 047 * Returns the filename for a descriptive image. 048 * @return a <code>String</code> value 049 */ 050 String getCover(); 051 052 /** 053 * Returns descriptive text about the nature of the questions. 054 * @return a <code>String</code> value 055 */ 056 String getDescription(); 057 058 /** 059 * Number of questions this chapter contains. 060 * @return an <code>int</code> value 061 */ 062 int getNumberOfQuestions(); 063 064 /** 065 * Gets the question with the specified ID or null if it doesn't exist. 066 * @param id a <code>String</code> value 067 * @return a <code>Question</code> value 068 */ 069 Question getQuestion(String id); 070 071 /** 072 * Returns the title of this chapter. 073 * @return a <code>String</code> value 074 */ 075 String getTitle(); 076 077 /** 078 * Returns all questions as a Collection 079 * @return a <code>Collection</code> value 080 */ 081 Collection<Question> getQuestionsCollection(); 082 083 /** 084 * Returns the chapter's questions as a read-only collection. 085 * @return a <code>Collection</code> value 086 */ 087 Collection<Question> getQuestionsReadOnly(); 088 089 /** 090 * Returns the chapter's title 091 * @return a <code>String</code> value 092 */ 093 String toString(); 094 095 /** 096 * Dumps the chapter in XML format to the 097 * given writer. Dumps all questions too. 098 * @param writer a <code>Writer</code> value 099 * @exception IOException if an error occurs 100 */ 101 void toXML(Writer writer) throws IOException; 102 103 }