package polling; import java.util.*; /** * A Question has a string and a collection of responses from * other students. It is used to keep a record of what students * have said */ public class Question{ /** * Response is used to keep track of what a specific student said * to a cetain question. */ class Response { /** * Username of the student */ User student; /** * An answer in generic form. It can be an integer or a string * depending on the question asked. */ K answer; } /** * Question holds the specified question that the instructor * is asking */ String question; /** * Holds each student and their answers to the specified question. */ Collection responses; /** * The ask command creates a new question for the instructor to ask * their students. */ /*@ //ensures */ public void ask(){ new Question(); } /** * Respond will be used by the student to answer the free * response questions or multiple choice. * @param std a user (mostly a student user) * @param ans an answer to the question in generic form as * an integer or string */ /*@ requires // // User be a valid user and that answer be a string or integer // std != null; ensures // // An answer is saved in the question by a particular user // \result.answer == ans; @*/ public Response respond(User std,K ans){ Response resp = new Response(); resp.student = std; resp.answer = ans; return resp; } } /** * A FreeResponse Question is used to seperate the two different * types of questions that will be asked. It holds two strings: * the question and the user's response. */ class FreeresponseQuestion extends Question { } /** * A MultipleChoice Question is used to seperate the two * different types of questions that will be asked. It holds the * correct answer for the multiple choice, a collection of * strings that contain the choices. */ class MultipleChoiceQuestion extends Question { /** * the correct answer number in the collection (counted like an array) */ int correctAnswer; /** * A collection of chioces that hold both the correct answer * and one or more incorrect answers. */ Collection choices; } /** * User is the student. It contains relevent information. */ class User { /*yet to decide format*/ }