18.10.2014 Views

COSC 1P03 Assignment 1

COSC 1P03 Assignment 1

COSC 1P03 Assignment 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

dimensional array (by question) indicating the correct answers. It should load these structures before<br />

beginning to administer the test.<br />

Since the questions may be multi-line and string I/O can only read a string from one line, each question<br />

in the file is one line long with # characters wherever the new lines should occur. The question strings<br />

can be converted into multi-line strings through the use of the replace function of the String class<br />

such as:<br />

quest = quest.replace(’#’,’\n’);<br />

The replace function produces a new string with is the same as the original string with each occurrence<br />

of # replaced by \n (the newline character). When written to a TextArea, such a string be written on<br />

a number of lines, breaking at the newline characters.<br />

In randomly selecting the questions for the student, duplication must be avoided. One way to do this is<br />

to have an array (by question) of boolean indicating whether the question has been asked (true) of<br />

the current student. Initially no questions have been asked (false). When selecting the next question<br />

to ask, check the array to see if the question has already been asked and continue randomly selecting a<br />

question until the selected question has not been asked. Then flag the question as asked.<br />

Submission:<br />

Details regarding preparation and submission of assignments in <strong>COSC</strong> <strong>1P03</strong> are found on the <strong>COSC</strong><br />

<strong>1P03</strong> website at URL: http://www.cosc.brocku.ca/Offerings/<strong>1P03</strong>/AssignGuide.pdf. This<br />

document includes a discussion of assignment preparation, programming standards, evaluation criteria<br />

and academic conduct (including styles for citation) in addition to the detailed assignment submission<br />

process copied below. Part of the marks for the assignment will be awarded for programming<br />

standards.<br />

To prepare and submit the assignment electronically from the lab, follow the procedure below:<br />

1. Ensure your folder (say Assign1) for the assignment is stored on your Z: drive.<br />

2. Using DrJava, print (to PDFCreator) the .java file of your assignment using the name<br />

ClassName.pdf where ClassName is the class name (i.e. same name as the .java<br />

file) and save the .pdf file at the top level of the project folder (i.e. directly within<br />

Assign1).<br />

3. Run your program for the assignment using the data file (from the A1Files folder)<br />

Test.dat for the question bank and the file Script.pdf as the script for your<br />

interaction with the forms presented by the program. Save the report as report.pdf at<br />

the top level (i.e. in the Assign1 folder).<br />

4. Run PuTTY by selecting PuTTY under All Programs in the Start menu.<br />

5. Double-click sandcastle in the Load, save … entry.<br />

6. Enter your Brock userid and press the Enter key.<br />

7. Once you have the sandcastle% prompt, navigate to your project directory for your<br />

assignment (say Assign1).<br />

Here are a few useful commands (press Enter after typing the command):<br />

ls –l<br />

cd <br />

cd ..<br />

- list files in current directory<br />

- changes to the specified subdirectory (note, do not<br />

include the )<br />

e.g. cd Assign1<br />

- go up 1 directory level

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

Saved successfully!

Ooh no, something went wrong!