12.07.2015 Views

Lab 8 (PDF) - Department of Computer Science

Lab 8 (PDF) - Department of Computer Science

Lab 8 (PDF) - Department of Computer Science

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Lab</strong> 8 1 Due Fri., 31 Mar.; Tues., 4 Apr.CMPSC 111Introduction to <strong>Computer</strong> <strong>Science</strong> ISpring 2006Bob RoosHome page: http://cs.allegheny.edu/~rroos/cs111s2006/<strong>Lab</strong> 8Questions and XInteract portion due Friday, 31 MarchJava program due Tuesday, 4 AprilCORRECTED ON MARCH 29Purpose: Review <strong>of</strong> methods, classes, arraysDetails:Get Programs and Question SheetFrom the class Web page, obtain copies <strong>of</strong> the three files TakeExam.java, Question.java, andExam.java. Also obtain a copy <strong>of</strong> lab8questions.txt, which is a plain text file.Compile and execute the program TakeExam to make sure it works. (It should just print out twoquestions about loops, followed by an error message saying “No such question as 2; returningnull”.)Answer the QuestionsThe question sheet is a way to guide you through the study <strong>of</strong> these three programs.Using Emacs, open the lab8questions.txt file for editing. Type your answers into this documentand print it out and hand it in when you are finished. Be sure to put your name at thetop.You are allowed to use the programs to experiment as you answer the questions!For instance, you can insert “println” statements anywhere in theprograms to print out values <strong>of</strong> variables, etc.Add Some CodeIn XInteract, there are four new problems that ask you to add more Java code to some <strong>of</strong> theclasses above. Work these exercises under the XInteract system.Add an Answer Submission FacilityModify the “Exam”, “Question”, and “TakeExam” classes as follows (some <strong>of</strong> these things you havealready done using XInteract):Add a new instance variable named answer <strong>of</strong> type String to the Question class. Modify theconstructor so that it takes a second String parameter and saves it in the new instance variable.Modify the TakeExam program so that it includes a solution string along with a question when ituses the Question constructor.Handed out on 29 March 2006 Handout # 13.5


<strong>Lab</strong> 8 3 Due Fri., 31 Mar.; Tues., 4 Apr.✷ Hard copy (printed using a2ps) <strong>of</strong> programs (by Tuesday)✷ Hard copy (printed using a2ps) <strong>of</strong> a sample run (by Tuesday)Handed out on 29 March 2006 Handout # 13.5

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!