THINK FIRST·CODE LATER

← All labs

User-story checker

Problem

Write a tool that checks user stories written as

As a <role>, I want <goal>, so that <benefit>

Read stories, one per line, until the end of input. For each story print Story k: followed by its problems, one per line starting with - , or - OK if there are none. Check, in this order (matching is case-insensitive):

  1. The line must start with as a or as an . Otherwise print - missing role and skip the other checks for this story.
  2. It must contain , i want → otherwise - missing goal.
  3. It must contain , so that → otherwise - missing benefit.
  4. For each vague word in this list that appears as a substring: fast, easy, user-friendly, etc, simple, flexible → - vague word: <word> (in list order).
  5. If the text between , i want and , so that (or to the end if there is no benefit) contains and → - goal has 'and': consider splitting.
  6. If the story has more than 30 words (split on spaces) → - too long (N words).

Finally print Stories: n, OK: k.

Input:

As a student, I want to post a question, so that classmates can help me
I want a fast app
As an instructor, I want to tag and hide exercises, so that Buddy is easy to control

Output:

Story 1:
- OK
Story 2:
- missing role
Story 3:
- vague word: easy
- goal has 'and': consider splitting
Stories: 3, OK: 1

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.

s3-1-data-1.txt

As a student, I want to post a question, so that classmates can help me
I want a fast app
As an instructor, I want to tag and hide exercises, so that Buddy is easy to control
What your program must print for s3-1-data-1.txt
Story 1:
- OK
Story 2:
- missing role
Story 3:
- vague word: easy
- goal has 'and': consider splitting
Stories: 3, OK: 1

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 < s3-1-data-1.txt

Windows PowerShell does not understand <:

Get-Content s3-1-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.