Assignment 1
Getting Started
- Read the Assignment Specification carefully
- Make sure you understand the assignment. Ask your tutor
or post a message on the message board if you have any questions.
- Don't try and start coding straight away. Solve the problem on
paper. Break down the problem into subproblems, and write down the
single steps. Discuss your design in the tute (Week 4 tute for those
who have a tute on Wednesday, Thursday or Friday. Week 5 tute for
everyone else)
- Then, start with the simpler tasks, like reading the dice
value, and implementing error checking of the input.
Plagiarism
Note that it is not ok to exchange code or pseudo
code with other students. We use plagiarism detection tools to check for
similarities in the submitted assignments.
Make sure that you don't leave hard copies of
your code, or disks with your code on it, in the labs. For more
information, read the course outline and the Yellow Form.
Updates
The updates written here are considered as part of the assignment
specification.
Please check for the updates regularly and as often as possible.
Clarification
-
Whitespaces as delimiter:
The whitespace as delimiter means one space or more spaces, excluding
new line character, EOF, and all other special characters. Thus, the
user input ends with a new line character, not EOF.
-
Dice rolling prompt:
For (re)rolling all dice, the prompt is to be "Please enter dice
values: ", and for rerolling some dice, the prompt is to be "Please
enter 1 value: ", "Please enter 2 values: ", etc.
-
Multi-digit numbers and floating-point numbers:
If the user enters multi-digit numbers such as 23, the program
should consider them as 2 and 3 without delimiter. If the user
enters floating-point numbers such as 2.3, the program should
consider them as 2 and 3 separated by '.'.
-
For dice value input:
Based on the clarification above, the program should yield
"Incorrect Input Format" error message, when a multi-digit number
or a floating-point number is entered.
-
For score option choices and rerolling option choices:
When 2.3 or 23 is entered, take '2' as a valid input and ignore
'.''3' or '3' respectively.
The page 2 of the spec specifies that "Invalid Choice" error
message needs to be printed out when 2.3 is entered. Please
ignore that, and follow this clarification.
"Invalid Choice" error message should be printed out only
when the first digit of the input is not between 1 and 3
(inclusive).
-
Rerolling options:
Even though the user is given two chance to reroll the dice, if the
user chooses to keep the dice after (re)rolling, the program shoud
print out the score options rather than printing out rerolling
options again.
-
Leading spaces:
If the user types leading space(s) in front of actual input value(s),
the program must ignore those space(s) and start processing the input
value(s)
-
Negative numbers:
-
For dice value input:
"Incorrect Input Format" error message is to be printed out, because the
program should treat any non-digit character, except the new line
character, as a delimiter and '-' is not a valid delimiter.
-
For score option choices and rerolling option choices:
"Invalid Choice" error message is to be printed out.
Typo Correction
- "New dice numbers need to be checked with the error conditions
in Section 2.1." ==> "New dice values need to be checked with
the error conditions in Section 2.1.": on page 5 before
section 3.2.
- "Pleaes choose" ==> "Please
choose": on page 6 in the example output section.
Testing
You can find the test files from http://www.cse.unsw.edu.au/~cs1917/16s2/ass/1/testfiles.tar.gz,
and the sample output from http://www.cse.unsw.edu.au/~cs1917/16s2/ass/1/output.tar.gz
In order to test your solution with the given testfiles, you must go into your
assignment directory, and uncompress the packages using:
tar -zxf testfiles.tar.gz
tar -zxf output.tar.gz
After uncompressing them, you will see two directories: testfiles
and output
. There are 70 test files in testfiles
directory.
By running
./assign1 < testfiles/FILENAME > result
diff -iEBbw output/FILENAME_output result
you can check if your program passes each test. FILENAME has to be the actual
filename such as 70stage2_chance and 18stage1_fourofakind, and
FILENAME_output has to be the actual filename found in output
directory such as 70stage2_chance_output and 18stage1_fourofakind_output. If the
diff
command shows you nothing after the run, it means that your
program has no problem with the test case.
Again, if nothing is displayed after running these commands, your program has
passed all the test cases provided.
Sample Solution
You can download the binary of the sample solution for the assignment from here.
After downloading the file, you should run
chmod a+x assign1_sample
to make it executable.