A friendly word of advice: in the design of this extension, think ahead to later when you will be implementing a GUI interface to PSAE. Try to implement this extension in terms of a common API to both the CLI user interface and the GUI user interface.
Here are the specific requirements for this project.
The -newQuestion command line argument should be followed by exactly 15 values. These values indicate the :TYPE, :CAT, :TITLE, :QUESTION, :DIFFICULTY, and exactly five :ANSWERs along with their associated point values. The point values will not be quoted, and each answer's point value will follow the string containing the answer. See the example below.
Your program should not crash if the user mistakenly provides less than 15 values on the command line following the -newQuestion command line argument. However, it does not need to be "smart" and recognize that only nine strings were provided to this argument and continue processing. If it cannot read 15 values following the -newQuestion argument, it should simply signal a command line error and quit. Note that if the user only provides 14 values and then provides some other command line argument, your program should process that command line argument as if it were the fifteenth value.
Zero, one, or more -newQuestion commands can be provided on the command line.
The program should write out a single line indicating that a new question was added, and its title.
All -newQuestion commands should be processed before any -answer commands. In other words, user-defined questions should be available to the user to answer.
Zero, one, or more -writeQuestions commands can be provided on the command line.
When a file is written, a line should be printed indicating what file was written and how many questions were written to it.
If the file exists and contains data, that data is overwritten. If the file does not exist, it is created. If the file specification is illegal, the program catch the problem without crashing and terminate processing at that point.
The file must be written out in legal psae format. In other words, once the file is written, it should be a legal argument to -qa in a future invocation of the system, and all questions should be read in without error.
% java -jar johnson-P4.jar -qa test.qa -writeQuestions "newtest.qa" Personal Self-Assessment Environment V4.0 Philip Johnson Loading question title: Question01 Loading question title: Question02 Loading question title: Question03 Loading question title: Question04 Loading question title: Question05 Loading question title: Question06 Loading question title: Question07 Loading question title: Question08 Loading question title: Question09 Loading question title: Question10 10 questions successfully loaded. Writing 10 questions to file newtest.qa.
% java -jar johnson-P4.jar -qa test.qa -newQuestion "MC:N" "Leap" "Author" "Who wrote Leap?" "50" "Cam" 100 "Philip" 0 "Robert" 0 "" 0 "" 0 Personal Self-Assessment Environment V4.0 Philip Johnson Loading question title: Question01 Loading question title: Question02 Loading question title: Question03 Loading question title: Question04 Loading question title: Question05 Loading question title: Question06 Loading question title: Question07 Loading question title: Question08 Loading question title: Question09 Loading question title: Question10 10 questions successfully loaded. Defining a new question: Author
% java -jar johnson-P4.jar -qa test.qa -newQuestion "MC:N" "Leap" "Author" "Who wrote Leap?" "50" "Cam" 100 "Philip" 0 "Robert" 0 "" 0 "" 0 -writeQuestions "foo.qa" Personal Self-Assessment Environment V4.0 Philip Johnson Loading question title: Question01 Loading question title: Question02 Loading question title: Question03 Loading question title: Question04 Loading question title: Question05 Loading question title: Question06 Loading question title: Question07 Loading question title: Question08 Loading question title: Question09 Loading question title: Question10 10 questions successfully loaded. Defining a new question: Author Writing 11 questions to file foo.qa
Note that other command line arguments could also be supplied.