Docsity

CECS 174 Programming: Developing Scantron, TimedScantron, Question, and QuizWhiz Classes -, Assignments of Computer Science

Toggle sidebar
bg1
CECS 174 Programming Assignment 10, Spring 2008, Todd Ebert
1. For this problem you are to develop the Scantron java class. This class will be used by another
class called QuizWhiz which will administer a quiz. Below you will find the fields and methods
that are to be used in defining the Scantron class. Your task is to implement the constructors and
methods in a .java file and successfully compile the file. (50 points)
/**
Class that models a Scantron. The Scantron will record quiz
responses and have methods for computing a student’s score and
determining if a quiz response is correct.
@author Your Name
public class Scantron
private String studentName;
private char[] response;
/**
@param numQuestions the number of questions on the quiz
*/
public Scantron(String studentName, int numQuestions)
{ /* implement */}
/**
@return number of questions on the quiz
*/
int numberOfQuestions()
{ /* implement */ }
/**
@param qNum question number (1-number of questions)
@param answer answer to question qNum
@return true if student response matches the answer
*/
isCorrect(int qNum, char answer)
{ /* implement */ }
/**
@return the response (a letter a-d) to question qNum
*/
public char getResponse(int qNum)
{ /* implement */ }
/** Sets the response to the given question number */
public void setResponse(int qNum, char resp)
{ /* implement */ }
1
pf3

Partial preview of the text

Download CECS 174 Programming: Developing Scantron, TimedScantron, Question, and QuizWhiz Classes - and more Assignments Computer Science in PDF only on Docsity!

CECS 174 Programming Assignment 10, Spring 2008, Todd Ebert

  1. For this problem you are to develop the Scantron java class. This class will be used by another class called QuizWhiz which will administer a quiz. Below you will find the fields and methods that are to be used in defining the Scantron class. Your task is to implement the constructors and methods in a .java file and successfully compile the file. (50 points)

/** Class that models a Scantron. The Scantron will record quiz responses and have methods for computing a student’s score and determining if a quiz response is correct. @author Your Name public class Scantron

private String studentName; private char[] response;

@param numQuestions the number of questions on the quiz / public Scantron(String studentName, int numQuestions) { / implement */}

@return number of questions on the quiz / int numberOfQuestions() { / implement */ }

@param qNum question number (1-number of questions) @param answer answer to question qNum @return true if student response matches the answer / isCorrect(int qNum, char answer) { / implement */ }

/** @return the response (a letter a-d) to question qNum / public char getResponse(int qNum) { / implement */ }

/** Sets the response to the given question number / public void setResponse(int qNum, char resp) { / implement */ }

@return returns the name of the student / public String getStudent() { / implement */ }

/** Sets the name of the student / public void setName(String name) { / implement */ }

public int numberCorrect(char[] answer) { /* implement */ } }

  1. Generate the javadoc for the Scantron class and all subsequent classes. Each method and constructor should have corresponding information about its use. (30 points)
  2. For this problem you are to develop the TimedScantron java class which extends the Scantron class. A TimedScantron is a Scantron that also keeps track of the quiz start time, end time, and has a method that returns the duration of the quiz. The method should return a String that indicates the number of minutes and seconds spent taking the exam. Other methods include void startQuiz(long startTime) and void endQuiz(long endTime). Implement TimedScantron in a .java file and successfully compile it. (30 points)
  3. For this problem you are to develop a Question class that is able to store a multiple-choice question. At the very least the Question class should be able to store both the question and possible answers to the question, as well as an indication of what the correct answer is to the question. Remember to include all appropriate accessors and setters. (30 points)
  4. Use the Scantron, TimedScantron, and Question classes to develop the QuizWhiz class. QuizWhiz should have a method called takeQuiz(). When the user selects takeQuiz(), he or she will be asked if the quiz is to be a timed quiz. If so, then the user inputs the number of minutes of the quiz, and the quiz begins. The quiz questions are to be stored in a local text file called quiz. The questions are read from the file in to a QuizWhiz object and presented to the user one at a time. The user has the choice of selecting one of the answer choices by inputting the appropriate letter (e.g. a-d if there are four possible answers), or the user may pass (by inputting ’p’) on the question and come back to it if time permits. If the user inputs an invalid choice, then he or she must be informed and given a chance to submit a correct answer. The user also has the option of quitting (’q’) at any time. At the end of the quiz the user is presented with the following:
    • the amount of time (in minutes and seconds) needed to take the quiz (only if it is a timed quiz);
    • number of questions answered (e.g. “5 out of 10”);
    • number of questions answered correctly along with a percentage that were answered correctly;