THINK FIRST·CODE LATER

← All labs

Decision table: who may view a post?

Problem

Implement StudyBuddy's visibility rule exactly as specified by this decision table, then use it to evaluate test cases.

Rule Deleted Author Staff (TA/instructor of the course) Enrolled in course Hidden Anonymous Result
1 Y – – – – – DENY
2 N Y – – – – FULL
3 N N Y – – – FULL
4 N N N N – – DENY
5 N N N Y Y – DENY
6 N N N Y N Y ANONYMOUS
7 N N N Y N N FULL

(– = does not matter. FULL = see the post with the author's name, ANONYMOUS = see it with "Anonymous student".) Rules are checked in order; the first matching rule applies.

Input: lines of six flags Y/N in the column order (deleted author staff enrolled hidden anonymous), until the end of input. For each line print flags -> RESULT (rule k). Then print how many times each rule was used: Rule usage: 1=a 2=b 3=c 4=d 5=e 6=f 7=g and Uncovered rules: ... (rules never used, in order, separated by , ) or Uncovered rules: none.

Input:

N N N Y N Y
N N N Y Y N
Y Y N Y N N
N N Y N Y Y

Output:

N N N Y N Y -> ANONYMOUS (rule 6)
N N N Y Y N -> DENY (rule 5)
Y Y N Y N N -> DENY (rule 1)
N N Y N Y Y -> FULL (rule 3)
Rule usage: 1=1 2=0 3=1 4=0 5=1 6=1 7=0
Uncovered rules: 2, 4, 7

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.