EECE 2140 · Week 11 · Class Project · Complete worked solution

Equipment Inventory Manager

Week #11 Mini Project: Component Stock Manager

Plan, implement, test, document, and release a complete console application. Allow 1–2 hours; the reference capstone can take longer.

Tools, prerequisites, and learning objectives

Tools: Ubuntu terminal (Linux or Windows with WSL), g++ supporting C++17, Git, Bash, a GitHub account, and an optional editor. File projects use supplied text fixtures. Week 3 also uses GDB; Week 8 uses compiler sanitizers.

Prerequisites: STL vectors, maps, and container operations.

Objectives: Represent records with containers; implement lookup; justify data-structure choice.

Provisional course alignment: C++ implementation, problem solving, development tools, testing, and technical communication; team projects additionally assess collaboration. Exact official syllabus objective numbers have not been supplied.

g++ --version
git --version
# Install missing tools in Ubuntu:
sudo apt update
sudo apt install build-essential git gdb

1. Understand the acceptance criteria

Represent records with containers; implement lookup; justify data-structure choice.

InputExpected output
meter
meter: 3
probe
Not found

Each row is an executable acceptance test. Input is read from standard input; output is printed to the terminal.

2. Create the repository and project folders

Create an empty GitHub repository named week11-class-project with a README, then substitute your username:

git clone https://github.com/YOUR-USERNAME/week11-class-project.git
cd week11-class-project
git switch -c feature/implementation
mkdir -p src tests .github/workflows
printf "build/\n" > .gitignore

3. Implement the complete solution

The following source is the worked solution. Read it first, predict the test results, then create the file from your terminal:

cat > src/main.cpp <<'EOF'
#include <iostream>
#include <map>
#include <string>
int main(){std::map<std::string,int> stock{{"meter",3},{"scope",2}};std::string name;if(!(std::cin>>name)){std::cout<<"Invalid input\n";return 0;}auto it=stock.find(name);if(it==stock.end())std::cout<<"Not found\n";else std::cout<<name<<": "<<it->second<<"\n";}
EOF

4. Create test fixtures

cat > tests/input1.txt <<'EOF'
meter
EOF
cat > tests/expected1.txt <<'EOF'
meter: 3
EOF
cat > tests/input2.txt <<'EOF'
probe
EOF
cat > tests/expected2.txt <<'EOF'
Not found
EOF

5. Build and test from the terminal

cat > test.sh <<'EOF'
#!/usr/bin/env bash
set -eu
mkdir -p build
g++ -std=c++17 -Wall -Wextra -pedantic src/main.cpp -o build/app
./build/app < tests/input1.txt > build/actual1.txt
diff -u tests/expected1.txt build/actual1.txt
./build/app < tests/input2.txt > build/actual2.txt
diff -u tests/expected2.txt build/actual2.txt
echo "All acceptance tests passed"
EOF
bash test.sh

The script stops on a compilation error or mismatched output. Successful completion prints “All acceptance tests passed”.

6. Automate with GitHub Actions

cat > .github/workflows/cpp.yml <<'EOF'
name: Build and test
on: [push, pull_request]
permissions:
  contents: read
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Compile and run acceptance tests
        run: bash test.sh
EOF
git add src tests test.sh .github .gitignore
git commit -m "Implement application with acceptance tests and CI"
git push -u origin feature/implementation

Open a pull request in GitHub, inspect its Actions logs, and merge only after checks pass. Intentionally alter one expected-output line on a temporary branch, observe the failure, then restore it. Do not change expectations to hide a defect.

7. Document and verify a release

Write README.md with purpose, input format, build/run/test commands, example output, limitations, and AI assistance. Include a short debugging reflection.

git switch main
git pull --ff-only
# Edit and commit README.md, then push.
cd ..
git clone https://github.com/YOUR-USERNAME/week11-class-project.git week11-verify
cd week11-verify
bash test.sh
git tag -a v1.0 -m "Verified class project"
git push origin v1.0

Completion: a fresh clone passes, the latest CI run is green, and the instructions reproduce your output.

Download and engineering review

Download the complete solution, tests, README, and workflow

Explain the data flow, validation choices, and how each test detects a failure. The downloadable solution is a learning reference, not a substitute for understanding the code.