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

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.