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

Data for this lab

Your program reads its data from standard input. Download the file, then give it to your program as shown below. Start with data set 1: its expected output is given.

s8-2-data-1.txt

N N N Y N Y
N N N Y Y N
Y Y N Y N N
N N Y N Y Y
What your program must print for s8-2-data-1.txt
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

Run your program first, then open this and compare line by line: your output must contain these lines exactly.

How to give the file to my program

Terminal (macOS, Linux, or Windows Command Prompt), after compiling:

java Main < s8-2-data-1.txt

Windows PowerShell does not understand <:

Get-Content s8-2-data-1.txt | java Main

IntelliJ IDEA: Run → Edit Configurations → Redirect input from. Or simply paste the content of the file into the console when the program waits for input.

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.