Programming labs
Write the program yourself, then compare with the model solution. The problems follow the chapters, from the first programs to object-oriented design.
CPS 4301 · 84 labs
The Ariane 5 conversion: detect overflow instead of hiding it
Ariane 5 was lost because a 64-bit floating-point value was converted to a 16-bit signed integer that could not hold it. In Java, a 16-bit signed inte...
Verify, then trust: fix the AI's leap-year code
An AI assistant wrote this method for StudyBuddy's calendar: [code] It looks right and works for 2023 and 2024 — but it is wrong. The real (Gregorian)...
Quality-attribute classifier for requirements
Lina collected StudyBuddy requirements from interviews. Write a program that sorts them by quality attribute using keyword rules, so the team can see...
The iceberg: lifetime cost of StudyBuddy
Most of a system's cost comes after the first release. Estimate StudyBuddy's lifetime cost. Input (one line): D P Y G - D — cost of the first version...
Failure autopsy: CrowdStrike, July 2024
On 19 July 2024 a faulty content update for a widely used security product crashed about 8.5 million Windows computers. Using public information (the...
StudyBuddy: stakeholders and quality priorities
Before writing any requirement, the team must know who cares about StudyBuddy and what "good" means for each of them. 1. List six stakeholders (people...
Little's law calculator
Little's law: WIP = throughput × cycle time. Given any two of the three values, compute the third. Read lines until the end of input. Each line has a...
A Kanban board that enforces WIP limits
Simulate StudyBuddy's Kanban board with four columns in this order: TODO, DOING, REVIEW, DONE. DOING and REVIEW have WIP limits; TODO and DONE are unl...
DORA metrics from a deployment log
Compute the four DORA metrics for StudyBuddy from its deployment log. Input: first line days n — the length of the period in days and the number of de...
Process advisor: agile, plan-driven or hybrid?
Implement a small advisor based on Boehm and Turner's five factors. Each project is one input line: [code] - criticality: 1 = loss of comfort, 2 = los...
Choose the process: three projects, three answers
For each project, recommend a process (plan-driven, agile, hybrid — be specific: V-model, Scrum, Kanban, spiral…), justify it with Boehm and Turner's...
Design StudyBuddy's team workflow with AI
Design the working process of the StudyBuddy team for the semester. Produce: 1. Sprint rhythm: Sprint length, the day and length of each Scrum event,...
User-story checker
Write a tool that checks user stories written as [code] Read stories, one per line, until the end of input. For each story print Story k: followed by...
Given/When/Then scenario validator
Acceptance criteria are only useful if they are well-formed. Validate one scenario written in Given/When/Then style. Read lines until the end of input...
Kano survey analysis
Classify StudyBuddy features with the Kano model. Each respondent answers two questions per feature: the functional question ("How would you feel if t...
Interview-question reviewer
Before interviewing instructors, Lina wants a tool that reviews her question list. Read questions, one per line, until the end of input. Classify each...
Fix a bad interview
Here is part of Lina's first interview with Dr. Wang, who teaches CPS 2231 (Java). Read it carefully. Lina: Hi! We're building StudyBuddy, an AI tutor...
Critique the AI: generated user stories
Omar asked an AI assistant: "Write 8 user stories for StudyBuddy's Q&A board." It returned: 1. As a user, I want a fast and user-friendly Q&A board, s...
Requirement linter with EARS detection
Write a linter for requirement sentences. Read lines until the end of input; each line is ID: text. For each requirement print its EARS pattern and it...
MoSCoW release planner
Plan a release with MoSCoW priorities and a fixed capacity. Input: first line capacity n; then n lines name priority effort where priority is M, S, C...
Traceability matrix: coverage and orphans
Build a traceability report linking requirements to tests. Input: [code] Output: 1. One line per requirement, in input order: REQ-ID: T1, T2 (its test...
Does Buddy's detector meet its requirement?
Buddy uses a detector that decides whether a question is about a graded exercise. The requirement is: On the instructor-labelled test set, recall for...
Repair a bad requirements section
This is section 3.2 ("Moderation") of StudyBuddy's first SRS draft: 1. The system should be able to handle inappropriate posts appropriately. 2. Posts...
Change request: "Buddy should also answer in Chinese"
In week 8, Dr. Wang submits a change request: "Many first-year students ask Buddy in Chinese. Buddy should answer in Chinese when the question is in C...
Planning-poker round
Simulate one round of planning poker. The deck is 1 2 3 5 8 13 21. Input: lines name vote until the end of input (each vote is a value from the deck)....
Three-point (PERT) project estimate
Estimate a sequence of independent tasks with three-point estimation. Input: lines task O M P until the end of input (O ≤ M ≤ P, real numbers, days)....
Critical path finder
Find the critical path of a task network. Input: first line n; then n lines TASK duration dep1,dep2,... (or - for no dependencies). Tasks may be liste...
Risk register: exposure and priorities
Turn a list of risks into a prioritized register. Input: lines id probability impactDays category until the end of input; probability is between 0 and...
Team charter and collaboration rules for StudyBuddy
Write the StudyBuddy team charter — a one-page agreement the five members sign in week 1: 1. Roles — who is Product Owner, who covers backend/mobile/t...
Plan the first release with velocity and risks
After Sprint 3, the StudyBuddy team has these data: - Velocities: Sprint 1 = 14, Sprint 2 = 21, Sprint 3 = 19 points. Sprints are 2 weeks. The semeste...
Coupling metrics and layer violations
Analyse StudyBuddy's module dependencies. Input: [code] The LAYERS line lists the layers from top to bottom. A module may depend only on modules in th...
Find dependency cycles
Dependency cycles make modules impossible to change independently. Find one. Input: lines from to until the end of input (module from depends on to)....
Resilient tutor: fallback and circuit breaker
Implement Buddy's resilience layer with dependency inversion. Define an interface Tutor with String answer(String question) throws Exception, and two...
Answer cache with TTL and LRU eviction
Before the midterm many students ask Buddy the same questions. Add a cache in front of the (expensive) AI call. Input: first line capacity ttl costPer...
Two ADRs for StudyBuddy
Write two architecture decision records in the Nygard format (title, status, context, decision, consequences with at least two positive and two negati...
Critique the AI: an over-engineered architecture
Aisha asked an AI assistant to "design a scalable, modern architecture for StudyBuddy". It proposed: 9 microservices (auth, users, courses, posts, vot...
Cyclomatic complexity meter
Estimate McCabe's cyclomatic complexity of Java methods. Input: several methods. Each method starts with a line METHOD name and ends with a line END....
Fix and clean the AI's late-penalty code
The syllabus rule for late submissions in StudyBuddy's "deadline" feature is: - submitted on time (0 days late or earlier) → full score; - 1 to 7 days...
Code-smell detector
Write a small smell detector for Java source code. Input: Java source code until the end of input. A method header is a line that (after trimming) sta...
Dependency check: hallucinated and typosquatted packages
Before merging an AI-generated build change, check its dependencies against the team's list of approved packages. Input: [code] For each requested dep...
Review an AI-generated pull request
Omar's pull request "Search posts by author" was generated with an AI assistant. The description says: "Adds search by author name. All tests pass ✅....
Write the prompt, then the verification plan
You will ask an AI assistant to implement StudyBuddy's study-partner matching method. Before you do: 1. Write the prompt as a mini-specification (cont...
Boundary-value test generator
Generate boundary-value tests for integer input fields. Input: lines field min max until the end of input (the valid range is min..max, inclusive, min...
Decision table: who may view a post?
Implement StudyBuddy's visibility rule exactly as specified by this decision table, then use it to evaluate test cases. Rule Deleted Author Staff (TA/...
Measure branch coverage by hand
Instrument a method to measure branch coverage. The method under test is StudyBuddy's reminder rule: [code] Each decision has two outcomes, so there a...
Post lifecycle: state-transition testing
A StudyBuddy post has the states DRAFT, PUBLISHED, HIDDEN, DELETED. The valid transitions are: From Event To --------- DRAFT publish PUBLISHED DRAFT d...
Design the tests for "hide after 3 reports"
Requirement MOD-2 (from Chapter 4), with details agreed with the TAs: When a post receives reports from 3 different students enrolled in the course, t...
Critique the AI: a generated JUnit test class
Daniel asked an AI assistant to "write thorough JUnit tests" for LatePenalty.scoreAfterLatePenalty(int score, int daysLate) (rules: full score if ≤ 0...
A tiny mutation-testing tool
Measure the strength of a test suite for StudyBuddy's pass rule: A student passes if score = 60 and attendance = 75 (percent), or if score = 90 (excel...
Properties as oracles: check an AI's slot merger
An AI wrote mergeSlots, which merges a student's free-time slots on one day. You do not trust it, but you also do not want to compute every expected a...
Load-test report with percentiles
Analyse the results of a StudyBuddy load test. Input: first line durationSeconds sloP95Ms maxErrorPercent. Then lines, one per request: either a respo...
Evaluation harness: may the new Buddy model be released?
Compare two versions of Buddy on a golden set and decide whether the new version may be released. Input: [code] - Golden item TYPE is ANSWER (Buddy mu...
System test plan for the midterm rush
Last year, a similar app crashed the night before the CPS 2231 midterm. StudyBuddy must survive the same night: about 600 active students, up to 300 c...
Build Buddy's golden evaluation set
Create the first version of Buddy's evaluation for CPS 2231 (Java). 1. Write 12 golden items in a table: id, category, the question, what a correct an...
Allow-list input validator
Validate StudyBuddy form fields on the server with allow-lists, and flag suspicious input for the security log. Input: lines field value... until the...
Complete mediation: the access-control check
Implement StudyBuddy's server-side authorization and check a batch of API requests — every request is checked (complete mediation), and anything not e...
Brute-force protection: account lockout
Implement requirement SEC-3 (an EARS requirement from Chapter 4): If a login for an account fails 5 times within 10 minutes, then the system shall loc...
SBOM vulnerability scanner
Scan StudyBuddy's software bill of materials against security advisories. Input: [code] Versions are dotted numbers such as 2.14.1 (compare them part...
Threat model StudyBuddy with STRIDE
Build a threat model for StudyBuddy's core system. 1. Draw a data-flow diagram (in text) with external entities (students, TAs/instructors, university...
Secure Buddy against prompt injection
Buddy uses RAG over (a) instructor-uploaded course files and (b) — a new feature request — endorsed answers from the Q&A board, written by students an...
Redact personal data before it reaches the AI provider
Before a student's question is sent to the external AI provider, StudyBuddy must remove identifiers. Read questions, one per line, until the end of in...
k-anonymity checker with generalization
The instructor wants a table of study statistics. Before release, check its k-anonymity with respect to the quasi-identifiers age, gender, major. Inpu...
Retention policy enforcer
Implement StudyBuddy's storage-limitation job, which runs every night. Input: [code] Days are integers (day numbers). An item must be deleted if today...
Privacy-safe statistics for instructors
Instructors may see Buddy usage statistics per group (course section), but a statistic for a small group can reveal individuals. Implement a report wi...
Privacy impact assessment for Buddy
Before Buddy is launched, the university's data-protection officer asks for a privacy impact assessment. Write it (about 1.5 pages) with these section...
Design the privacy controls: consent, rights and deletion
Design the privacy user experience and back-end procedures for StudyBuddy: 1. Onboarding: the screens a new student sees about privacy (text and choic...
Licence compatibility checker
Check StudyBuddy's dependencies against its distribution mode and project licence using these simplified rules (not legal advice): - Licence families:...
Third-party notices generator
Permissive licences require that copyright and licence notices travel with the product. Generate StudyBuddy's THIRD-PARTY NOTICES screen. Input: lines...
Did the AI copy licensed code? A similarity scanner
AI assistants sometimes reproduce licensed code nearly verbatim. Build a simple scanner that compares a generated snippet with known licensed snippets...
EU AI Act risk triage (simplified)
Before building an AI feature, StudyBuddy's team runs a first triage of its EU AI Act risk level (simplified — the result must be confirmed by legal e...
Ethics case: the AI-writing detector
The department asks the StudyBuddy team to add a feature: "Automatically check every Q&A post and lab report with an AI-text detector. Posts scoring a...
IP and licensing plan for StudyBuddy
At the end of the semester, a local education company offers to "take over StudyBuddy" and sell it to other universities. Before anyone signs anything...
Error-budget tracker
Track StudyBuddy's availability error budget. Input: first line sloPercent windowDays (e.g. 99.5 30). Then incidents, one per line: name minutesDown,...
Canary analysis: promote or roll back?
A new StudyBuddy release is rolled out in stages. At each stage the canary (new version) and the baseline (old version) serve traffic at the same time...
Software Carbon Intensity calculator
Compare the Software Carbon Intensity of design options for Buddy using the SCI formula SCI = ((E × I) + M) / R. Input: first line gridIntensity (gCO₂...
Technical-debt register: what to repay first?
Plan technical-debt repayment for the next Sprint. Input: first line capacityHours. Then items id principalHours interestHoursPerSprint risk until the...
Blameless postmortem: the midterm-night outage
Write a complete blameless postmortem (about one page) for this incident: On the evening before the CPS 2231 midterm, StudyBuddy's board and Buddy bec...
Sustainability review of StudyBuddy
Perform a sustainability review of StudyBuddy covering the three dimensions of this chapter. 1. Environmental: identify the five largest likely source...
Autonomy-level advisor
Decide the maximum AI autonomy level (L0–L5, as in this chapter) allowed for proposed tasks. Input: lines task risk reversibility data checks until th...
Audit a coding agent's action log
An agent worked on "fix issue 214 in the matching module". Audit its action log against the team's guardrails. Input: first line ALLOW path1,path2,......
Is it really done? Checking an agent's claim against the spec
An agent reports: "Issue 214 is done." Verify the claim with the specification and the test results. Input: [code] A criterion is: - MET if it has at...
The review bottleneck: simulate agent PRs vs. human review
Agents can open pull requests faster than humans can review them. Simulate the review queue day by day. Input: first line days reviewCapacity wipLimit...
StudyBuddy final demo and oral defense
Prepare the final presentation of StudyBuddy (15 minutes + 10 minutes of questions). 1. Write the demo script: the order of what you show, which perso...
My professional position on AI in software engineering
Write a personal professional position statement (about one page) that you could show to a future employer: 1. My principles for using AI in engineeri...