Essay - // a file....

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// **************************************************************** // Essay.java // // A class that defines an essay test question by extending class // TestQuestion. // // **************************************************************** import java.util.Scanner; public class Essay extends TestQuestion { private int numLines; //--------------------------------------- // Reads the next question from the standard input. // Note that although the directions call for readQuestion to be a // parameterless question, it needs to take the Scanner // as a parameter to read correctly if the input is redirected from
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // a file. //---------------------------------------protected void readQuestion(Scanner scan) { numLines = scan.nextInt(); //eat up newline after integer question = scan.nextLine(); //read question question = scan.nextLine(); } //---------------------------------------// Returns the formatted question as a string. //---------------------------------------public String toString() { String ans = question; for (int i=0; i<numLines; i++) ans += "\n"; return ans; } }...
View Full Document

This note was uploaded on 03/22/2010 for the course CS 202 taught by Professor Fong during the Spring '10 term at SIU Carbondale.

Ask a homework question - tutors are online