diff --git a/.github/workflows/autograder.yml b/.github/workflows/autograder.yml new file mode 100644 index 0000000..469acc8 --- /dev/null +++ b/.github/workflows/autograder.yml @@ -0,0 +1,84 @@ +name: C++ Classroom Autograder + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build-and-test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y cmake build-essential + + - name: Create build directory + run: mkdir build + + - name: Configure CMake + run: cd build && cmake .. + + - name: Build + run: cd build && make + + - name: Run tests + run: cd build && ctest --output-on-failure + + - name: Run assignment executables + run: | + echo "Running Assignment 1:" + cd build && ./assignments/assignment1/assignment1 + + grade-assignment: + needs: build-and-test + runs-on: ubuntu-latest + if: always() + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y cmake build-essential + + - name: Build and test with detailed output + id: test + run: | + mkdir build + cd build + cmake .. + make + echo "TESTS_OUTPUT<> $GITHUB_OUTPUT + ctest --verbose >> $GITHUB_OUTPUT || echo "Tests failed" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Generate Grade Report + run: | + echo "# πŸ“Š Autograding Report" >> grade_report.md + echo "" >> grade_report.md + echo "## Build Status: βœ… PASSED" >> grade_report.md + echo "" >> grade_report.md + echo "## Test Results:" >> grade_report.md + echo '```' >> grade_report.md + cd build && ctest --verbose || echo "Some tests failed" + echo '```' >> grade_report.md + echo "" >> grade_report.md + echo "## πŸ’‘ Tips for Improvement:" >> grade_report.md + echo "- Ensure all functions are implemented correctly" >> grade_report.md + echo "- Check that your code handles edge cases" >> grade_report.md + echo "- Make sure to follow the function signatures in the header file" >> grade_report.md + + - name: Upload grade report + uses: actions/upload-artifact@v4 + with: + name: grade-report + path: grade_report.md \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..474414f --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +# C++ build artifacts +build/ +*.o +*.obj +*.exe +*.dll +*.so +*.a +*.lib + +# CMake +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake +Makefile +*.cmake +!CMakeLists.txt + +# IDE files +.vscode/ +.idea/ +*.vcxproj* +*.sln +*.suo +*.user + +# Test results +test_results/ +*.xml + +# OS files +.DS_Store +Thumbs.db + +# Temporary files +*.tmp +*.temp +*~ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c322ce4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.14) +project(CPPClassroom) + +# Set C++ standard +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Add compiler flags for better error messages and debugging +set(CMAKE_CXX_FLAGS "-Wall -Wextra -g") + +# Include FetchContent for downloading dependencies +include(FetchContent) + +# Fetch Google Test +FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG release-1.12.1 +) + +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) + +# Enable testing +enable_testing() + +# Add subdirectories for assignments +add_subdirectory(assignments/assignment1) + +# Optionally add more assignments as they are created +# add_subdirectory(assignments/assignment2) +# add_subdirectory(assignments/assignment3) \ No newline at end of file diff --git a/INSTRUCTOR_GUIDE.md b/INSTRUCTOR_GUIDE.md new file mode 100644 index 0000000..cf2a986 --- /dev/null +++ b/INSTRUCTOR_GUIDE.md @@ -0,0 +1,200 @@ +# πŸ‘¨β€πŸ« Instructor Guide - C++ Classroom + +## Overview +This repository has been set up as a complete C++ programming classroom with automated testing and grading capabilities. Students can submit assignments and receive instant feedback through GitHub Actions. + +## 🎯 Key Features +- βœ… **Automated Testing**: Unit tests run on every commit/push +- βœ… **Professional Build System**: CMake + Google Test framework +- βœ… **Instant Feedback**: Grade reports generated automatically +- βœ… **Scalable**: Easy to add new assignments +- βœ… **Student-Friendly**: Helper scripts and clear documentation + +## πŸ“ Repository Structure + +``` +β”œβ”€β”€ assignments/ +β”‚ └── assignment1/ # Example: Hello World with Functions +β”‚ β”œβ”€β”€ src/ # Student code goes here +β”‚ β”œβ”€β”€ include/ # Header files +β”‚ β”œβ”€β”€ tests/ # Unit tests (instructor-created) +β”‚ β”œβ”€β”€ CMakeLists.txt # Build config +β”‚ └── README.md # Assignment instructions +β”œβ”€β”€ template/ # Template for creating new assignments +β”œβ”€β”€ .github/workflows/ # GitHub Actions for autograding +β”œβ”€β”€ CMakeLists.txt # Root build configuration +β”œβ”€β”€ run_tests.sh # Student helper script +└── README.md # Student documentation +``` + +## πŸš€ Quick Start for Instructors + +### Adding New Assignments + +1. **Copy the template:** + ```bash + cp -r template assignments/assignment2 + cd assignments/assignment2 + ``` + +2. **Customize the assignment:** + - Edit `CMakeLists.txt`: Change `ASSIGNMENT_NAME` to "assignment2" + - Write assignment code in `src/` and `include/` + - Create comprehensive tests in `tests/` + - Update `README.md` with assignment instructions + +3. **Add to build system:** + ```cmake + # In root CMakeLists.txt, add: + add_subdirectory(assignments/assignment2) + ``` + +4. **Test locally:** + ```bash + ./run_tests.sh assignment2 + ``` + +### Example Assignment Structure +The included Assignment 1 demonstrates: +- **Function declarations** in header files (`include/hello.h`) +- **Implementation** in source files (`src/hello.cpp`) +- **Main program** (`src/main.cpp`) +- **Comprehensive unit tests** (`tests/test_hello.cpp`) + +## πŸ§ͺ Testing Strategy + +### Unit Tests (Google Test) +- Test individual functions with various inputs +- Include edge cases (empty strings, negative numbers, etc.) +- Verify return types and expected behavior +- Example test structure: + ```cpp + TEST(AssignmentTest, FunctionName) { + EXPECT_EQ(myFunction(input), expected_output); + EXPECT_TRUE(boolFunction(input)); + } + ``` + +### Integration Tests +- Test complete program functionality +- Verify all components work together +- Can be added to the same test files + +## πŸ“Š Autograding System + +### GitHub Actions Workflow +Located in `.github/workflows/autograder.yml`: + +1. **Build Phase**: Compiles all assignments with CMake +2. **Test Phase**: Runs all unit tests with CTest +3. **Execution Phase**: Runs assignment executables +4. **Reporting**: Generates grade reports and artifacts + +### Viewing Results +Students can see results in: +- **GitHub Actions tab**: Full build and test logs +- **Artifacts**: Downloadable grade reports +- **Console output**: Immediate feedback on failures + +### Customizing Grading +- Modify point distribution in workflow file +- Add custom grading logic in test files +- Create rubric-based assessments + +## πŸ‘₯ Student Workflow + +1. **Clone repository** (already done via GitHub Classroom) +2. **Navigate to assignment** folder +3. **Read instructions** in assignment README +4. **Implement solution** in designated files +5. **Test locally** with `./run_tests.sh` +6. **Submit via git**: `git add . && git commit -m "Solution" && git push` +7. **View results** in GitHub Actions + +## πŸ”§ Maintenance + +### Adding Dependencies +To add C++ libraries: +```cmake +# In CMakeLists.txt +FetchContent_Declare( + library_name + GIT_REPOSITORY https://github.com/user/library.git + GIT_TAG version +) +FetchContent_MakeAvailable(library_name) +``` + +### Updating Test Framework +The system uses Google Test 1.12.1. To update: +```cmake +# In root CMakeLists.txt, change: +GIT_TAG release-1.14.0 # or newer version +``` + +### Platform Compatibility +Current setup supports: +- βœ… Linux (Ubuntu 20.04+) +- βœ… macOS (with Xcode command line tools) +- βœ… Windows (with Visual Studio or MinGW) + +## πŸ“‹ Assignment Ideas + +### Beginner Level +- **Assignment 1** (included): Functions, strings, basic I/O +- **Variables and Types**: Data type exploration +- **Control Flow**: Loops, conditionals, switch statements +- **Arrays**: Basic array manipulation + +### Intermediate Level +- **Classes and Objects**: OOP fundamentals +- **Dynamic Memory**: Pointers and memory management +- **File I/O**: Reading/writing files +- **STL Containers**: Vector, map, set usage + +### Advanced Level +- **Templates**: Generic programming +- **Exception Handling**: Error management +- **Multi-threading**: Basic parallelism +- **Design Patterns**: Common programming patterns + +## πŸ› οΈ Troubleshooting + +### Common Issues + +**Build Failures:** +- Check CMakeLists.txt syntax +- Verify all source files are included +- Ensure proper include paths + +**Test Failures:** +- Review test logic and expected outputs +- Check for missing edge cases +- Verify function signatures match headers + +**GitHub Actions Issues:** +- Check workflow YAML syntax +- Verify Ubuntu package names in dependencies +- Monitor action execution logs + +### Getting Help +- Review GitHub Actions logs for detailed error messages +- Test locally before pushing to identify issues early +- Use the included `run_tests.sh` for consistent local testing + +## πŸ“ˆ Scaling the Classroom + +### For Larger Classes +- Use GitHub Teams for group assignments +- Implement branch protection rules +- Consider submission deadlines in workflow + +### Advanced Features +- Add code quality checks (linting, static analysis) +- Implement plagiarism detection +- Create performance benchmarking tests +- Add documentation generation + +--- + +**Happy Teaching! πŸŽ“** This system is designed to scale with your needs and provide students with immediate, actionable feedback on their C++ programming assignments. \ No newline at end of file diff --git a/README.md b/README.md index c488e13..bbc7f75 100644 --- a/README.md +++ b/README.md @@ -1,108 +1,213 @@ [![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-24ddc0f5d75046c5622901739e7c5dd533143b0c8e959d652212380cedb1ea36.svg)](https://classroom.github.com/a/X9GC_Rod) -# :wave: The Basics of GitHub -## πŸ€“ Course overview and learning outcomes +# πŸš€ C++ Programming Classroom + +Welcome to the C++ Programming Classroom! This repository is set up for automated testing and grading of C++ programming assignments. + +## πŸ“‹ Course Overview + +This classroom provides a complete environment for C++ programming assignments with: +- βœ… **Automated Testing** - Your code is tested automatically when you submit +- πŸ—οΈ **CMake Build System** - Professional C++ project structure +- πŸ§ͺ **Google Test Framework** - Industry-standard unit testing +- πŸ“Š **Autograding** - Instant feedback on your submissions +- 🎯 **GitHub Actions CI/CD** - Continuous integration and deployment + +## πŸ—οΈ Repository Structure + +``` +πŸ“ c-programming-group2-sverghes/ +β”œβ”€β”€ πŸ“ assignments/ # All programming assignments +β”‚ β”œβ”€β”€ πŸ“ assignment1/ # Hello World with Functions +β”‚ β”‚ β”œβ”€β”€ πŸ“ src/ # Your source code (.cpp files) +β”‚ β”‚ β”œβ”€β”€ πŸ“ include/ # Header files (.h/.hpp files) +β”‚ β”‚ β”œβ”€β”€ πŸ“ tests/ # Unit tests +β”‚ β”‚ β”œβ”€β”€ CMakeLists.txt # Build configuration +β”‚ β”‚ └── README.md # Assignment instructions +β”‚ └── πŸ“ assignment2/ # Future assignments... +β”œβ”€β”€ πŸ“ template/ # Template for new assignments +β”œβ”€β”€ πŸ“ .github/workflows/ # Automated testing configuration +β”œβ”€β”€ CMakeLists.txt # Main build configuration +└── README.md # This file +``` + +## πŸš€ Getting Started + +### Prerequisites +- **Git** - for version control +- **CMake** (3.14+) - build system +- **C++ Compiler** - GCC 7+ or Clang 7+ or MSVC 2017+ +- **Internet connection** - for downloading Google Test + +### Local Development Setup + +1. **Clone the repository** + ```bash + git clone + cd c-programming-group2-sverghes + ``` + +2. **Build all assignments** + ```bash + mkdir build + cd build + cmake .. + make + ``` + +3. **Run tests** + ```bash + ctest + ``` + +4. **Run a specific assignment** + ```bash + ./assignments/assignment1/assignment1 + ``` + +## πŸ“ Working on Assignments + +### Step 1: Navigate to Your Assignment +```bash +cd assignments/assignment1 # or assignment2, etc. +``` + +### Step 2: Read the Instructions +Each assignment has a `README.md` with: +- Objective and requirements +- Function specifications +- Expected inputs/outputs +- Grading criteria + +### Step 3: Implement Your Solution +- Write your **header files** in `include/` +- Write your **source code** in `src/` +- Follow the function signatures provided + +### Step 4: Test Locally +```bash +# From the root directory +mkdir -p build && cd build +cmake .. +make +ctest # Run all tests +./assignments/assignment1/assignment1 # Run your program +``` + +### Step 5: Submit Your Work +```bash +git add . +git commit -m "Complete assignment 1" +git push +``` + +## πŸ§ͺ Testing and Grading + +### Automated Testing +When you push code, GitHub Actions will: +1. **Build** your project +2. **Run all tests** +3. **Generate a grade report** +4. **Provide feedback** on what passed/failed + +### Test Types +- **Unit Tests** - Test individual functions +- **Integration Tests** - Test complete programs +- **Edge Cases** - Test boundary conditions +- **Code Quality** - Check for warnings/errors + +### Viewing Results +- Go to **Actions** tab in GitHub +- Click on the latest workflow run +- View the test results and grade report +- Download artifacts for detailed feedback + +## πŸ’‘ Tips for Success + +### Code Quality +- βœ… Use meaningful variable names +- βœ… Add comments for complex logic +- βœ… Follow consistent formatting +- βœ… Handle edge cases appropriately + +### Testing Strategy +- πŸ§ͺ Test your code before submitting +- πŸ§ͺ Consider edge cases (empty inputs, negative numbers, etc.) +- πŸ§ͺ Verify function return types match specifications +- πŸ§ͺ Test with different input values + +### Common Issues +❌ **Build Failures** +- Check for syntax errors +- Ensure all required files exist +- Verify function signatures match headers + +❌ **Test Failures** +- Read test output carefully +- Check expected vs actual values +- Verify your logic handles all cases + +❌ **Missing Files** +- Ensure you have all required source files +- Check that headers are included properly +- Verify CMakeLists.txt references all files + +## πŸ“š Current Assignments + +### Assignment 1: Hello World with Functions +**Status:** βœ… Available +**Objective:** Learn basic C++ functions, strings, and arithmetic +**Due:** Check assignment README for deadline + +**Key Learning Goals:** +- Function declaration and definition +- String manipulation +- Basic arithmetic operations +- Boolean logic + +[View Assignment 1 β†’](assignments/assignment1/README.md) + +## πŸ”§ For Instructors + +### Adding New Assignments + +1. **Copy the template** + ```bash + cp -r template assignments/assignment3 + ``` + +2. **Update the assignment** + - Modify `CMakeLists.txt` with new assignment name + - Write assignment-specific code and tests + - Update `README.md` with instructions + +3. **Add to build system** + ```cmake + # In root CMakeLists.txt + add_subdirectory(assignments/assignment3) + ``` + +### Customizing Auto-grading +- Edit `.github/workflows/autograder.yml` +- Add custom test cases in each assignment's `tests/` directory +- Modify grading criteria and point distribution + +## πŸ†˜ Getting Help + +### Resources +- **C++ Reference**: https://cppreference.com/ +- **CMake Documentation**: https://cmake.org/documentation/ +- **Google Test Primer**: https://google.github.io/googletest/primer.html + +### Support +- Check the **Issues** tab for common problems +- Review **failed test outputs** in GitHub Actions +- Ask questions in class or office hours + +## πŸ“„ License + +This classroom repository is for educational purposes. Code submissions are subject to academic integrity policies. + +--- -The goal of this course is to give you a brief introduction to GitHub. We’ll also provide you with materials for further learning and a few ideas to get you started on our platform. πŸš€ - -## :octocat: Git and GitHub - -Git is a **distributed Version Control System (VCS)**, which means it is a useful tool for easily tracking changes to your code, collaborating, and sharing. With Git you can track the changes you make to your project so you always have a record of what you’ve worked on and can easily revert back to an older version if need be. It also makes working with others easierβ€”groups of people can work together on the same project and merge their changes into one final source! - -GitHub is a way to use the same power of Git all online with an easy-to-use interface. It’s used across the software world and beyond to collaborate and maintain the history of projects. - -GitHub is home to some of the most advanced technologies in the world. Whether you're visualizing data or building a new game, there's a whole community and set of tools on GitHub that can get you to the next step. This course starts with the basics of GitHub, but we'll dig into the rest later. - -## :octocat: Understanding the GitHub flow - -The GitHub flow is a lightweight workflow that allows you to experiment and collaborate on your projects easily, without the risk of losing your previous work. - -### Repositories - -A repository is where your project work happens--think of it as your project folder. It contains all of your project’s files and revision history. You can work within a repository alone or invite others to collaborate with you on those files. - -### Cloning - -When a repository is created with GitHub, it’s stored remotely in the ☁️. You can clone a repository to create a local copy on your computer and then use Git to sync the two. This makes it easier to fix issues, add or remove files, and push larger commits. You can also use the editing tool of your choice as opposed to the GitHub UI. Cloning a repository also pulls down all the repository data that GitHub has at that point in time, including all versions of every file and folder for the project! This can be helpful if you experiment with your project and then realize you liked a previous version more. -To learn more about cloning, read ["Cloning a Repository"](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository). - -### Committing and pushing -**Committing** and **pushing** are how you can add the changes you made on your local machine to the remote repository in GitHub. That way your instructor and/or teammates can see your latest work when you’re ready to share it. You can make a commit when you have made changes to your project that you want to β€œcheckpoint.” You can also add a helpful **commit message** to remind yourself or your teammates what work you did (e.g. β€œAdded a README with information about our project”). - -Once you have a commit or multiple commits that you’re ready to add to your repository, you can use the push command to add those changes to your remote repository. Committing and pushing may feel new at first, but we promise you’ll get used to it πŸ™‚ - -## πŸ’» GitHub terms to know - -### Repositories -We mentioned repositories already, they are where your project work happens, but let’s talk a bit more about the details of them! As you work more on GitHub you will have many repositories which may feel confusing at first. Fortunately, your ["GitHub dashboard"](https://docs.github.com/en/github/setting-up-and-managing-your-github-user-account/about-your-personal-dashboard) helps to easily navigate to your repositories and see useful information about them. Make sure you’re logged in to see it! - -Repositories also contain **README**s. You can add a README file to your repository to tell other people why your project is useful, what they can do with your project, and how they can use it. We are using this README to communicate how to learn Git and GitHub with you. πŸ˜„ -To learn more about repositories read ["Creating, Cloning, and Archiving Repositories](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-repositories) and ["About README's"](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-readmes). - -### Branches -You can use branches on GitHub to isolate work that you do not want merged into your final project just yet. Branches allow you to develop features, fix bugs, or safely experiment with new ideas in a contained area of your repository. Typically, you might create a new branch from the default branch of your repositoryβ€”main. This makes a new working copy of your repository for you to experiment with. Once your new changes have been reviewed by a teammate, or you are satisfied with them, you can merge your changes into the default branch of your repository. -To learn more about branching, read ["About Branches"](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-branches). - -### Forks -A fork is another way to copy a repository, but is usually used when you want to contribute to someone else’s project. Forking a repository allows you to freely experiment with changes without affecting the original project and is very popular when contributing to open source software projects! -To learn more about forking, read ["Fork a repo"](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) - -### Pull requests -When working with branches, you can use a pull request to tell others about the changes you want to make and ask for their feedback. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add more changes if need be. You can add specific people as reviewers of your pull request which shows you want their feedback on your changes! Once a pull request is ready-to-go, it can be merged into your main branch. -To learn more about pull requests, read ["About Pull Requests"](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests). - - -### Issues -Issues are a way to track enhancements, tasks, or bugs for your work on GitHub. Issues are a great way to keep track of all the tasks you want to work on for your project and let others know what you plan to work on. You can also use issues to tell a favorite open source project about a bug you found or a feature you think would be great to add! - -For larger projects, you can keep track of many issues on a project board. GitHub Projects help you organize and prioritize your work and you can read more about them [in this "About Project boards document](https://docs.github.com/en/github/managing-your-work-on-github/about-project-boards). You likely won’t need a project board for your assignments, but once you move on to even bigger projects, they’re a great way to organize your team’s work! -You can also link together pull requests and issues to show that a fix is in progress and to automatically close the issue when someone merges the pull request. -To learn more about issues and linking them to your pull requests, read ["About Issues"](https://docs.github.com/en/github/managing-your-work-on-github/about-issues). - -### Your user profile - -Your profile page tells people the story of your work through the repositories you're interested in, the contributions you've made, and the conversations you've had. You can also give the world a unique view into who you are with your profile README. You can use your profile to let future employers know all about you! -To learn more about your user profile and adding and updating your profile README, read ["Managing Your Profile README"](https://docs.github.com/en/github/setting-up-and-managing-your-github-profile/managing-your-profile-readme). - -### Using markdown on GitHub - -You might have noticed already, but you can add some fun styling to your issues, pull requests, and files. ["Markdown"](https://guides.github.com/features/mastering-markdown/) is an easy way to style your issues, pull requests, and files with some simple syntax. This can be helpful to organize your information and make it easier for others to read. You can also drop in gifs and images to help convey your point! -To learn more about using GitHub’s flavor of markdown, read ["Basic Writing and Formatting Syntax"](https://docs.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax). - -### Engaging with the GitHub community - -The GitHub community is vast. There are many types of people who use GitHub in their day to dayβ€”students like you, professional developers, hobbyists working on open source projects, and explorers who are just jumping into the world of software development on their own. There are many ways you can interact with the larger GitHub community, but here are three places where you can start. - -#### Starring repositories - -If you find a repository interesting or you want to keep track of it, star it! When you star a repository it’s also used as a signal to surface better recommendations on github.com/explore. If you’d like to get back to your starred repositories you can do so via your user profile. -To learn more about starring repositories, read ["Saving Repositories with Stars"](https://docs.github.com/en/github/getting-started-with-github/saving-repositories-with-stars). - -#### Following users - -You can follow people on GitHub to receive notifications about their activity and discover projects in their communities. When you follow a user, their public GitHub activity will show up on your dashboard so you can see all the cool things they are working on. -To learn more about following users, read ["Following People"](https://docs.github.com/en/github/getting-started-with-github/following-people). - -#### Browsing GitHub Explore - -GitHub Explore is a great place to do just that … explore :smile: You can find new projects, events, and developers to interact with. - -You can check out the GitHub Explore website [at github.com/explore](https://github.com/explore). The more you interact with GitHub the more tailored your Explore view will be. - -## πŸ“ Optional next steps - -* Open a pull request and let your teacher know that you’ve finished this course. -* Create a new markdown file in this repository. Let them know what you learned and what you are still confused about! Experiment with different styles! -* Create your profile README. Let the world know a little bit more about you! What are you interested in learning? What are you working on? What's your favorite hobby? Learn more about creating your profile README in the document, ["Managing Your Profile README"](https://docs.github.com/en/github/setting-up-and-managing-your-github-profile/managing-your-profile-readme). -* Go to your user dashboard and create a new repository. Experiment with the features within that repository to familiarize yourself with them. -* [Let us know what you liked or didn’t like about the content of this course](https://support.github.com/contact/education). What would you like to see more of? What would be interesting or helpful to your learning journey? - -## πŸ“š Resources -* [A short video explaining what GitHub is](https://www.youtube.com/watch?v=w3jLJU7DT5E&feature=youtu.be) -* [Git and GitHub learning resources](https://docs.github.com/en/github/getting-started-with-github/git-and-github-learning-resources) -* [Understanding the GitHub flow](https://guides.github.com/introduction/flow/) -* [How to use GitHub branches](https://www.youtube.com/watch?v=H5GJfcp3p4Q&feature=youtu.be) -* [Interactive Git training materials](https://githubtraining.github.io/training-manual/#/01_getting_ready_for_class) -* [GitHub's Learning Lab](https://lab.github.com/) -* [Education community forum](https://education.github.community/) -* [GitHub community forum](https://github.community/) +**Happy Coding! 🎯** Remember to start early, test often, and don't hesitate to ask for help! \ No newline at end of file diff --git a/assignments/assignment1/CMakeLists.txt b/assignments/assignment1/CMakeLists.txt new file mode 100644 index 0000000..303c8b2 --- /dev/null +++ b/assignments/assignment1/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.14) + +set(ASSIGNMENT_NAME "assignment1") +project(${ASSIGNMENT_NAME}) + +# Include directories +include_directories(include) + +# Source files for the main executable +set(SOURCES + src/main.cpp + src/hello.cpp +) + +# Create main executable +add_executable(${ASSIGNMENT_NAME} ${SOURCES}) + +# Source files for testing (exclude main.cpp since it has its own main) +set(TEST_SOURCES + tests/test_hello.cpp + src/hello.cpp +) + +# Create test executable +add_executable(${ASSIGNMENT_NAME}_tests ${TEST_SOURCES}) + +# Link Google Test +target_link_libraries(${ASSIGNMENT_NAME}_tests gtest_main gtest) + +# Add test +add_test(NAME ${ASSIGNMENT_NAME}_tests COMMAND ${ASSIGNMENT_NAME}_tests) \ No newline at end of file diff --git a/assignments/assignment1/README.md b/assignments/assignment1/README.md new file mode 100644 index 0000000..8322fd2 --- /dev/null +++ b/assignments/assignment1/README.md @@ -0,0 +1,41 @@ +# Assignment 1: Hello World with Functions + +## Objective +Create a simple C++ program that demonstrates basic programming concepts including functions, variables, and output. + +## Requirements + +1. **Create a header file** (`include/hello.h`) with function declarations +2. **Implement functions** in a source file (`src/hello.cpp`) that: + - `greet(string name)` - returns a greeting message with the given name + - `add(int a, int b)` - returns the sum of two integers + - `isEven(int number)` - returns true if the number is even, false otherwise + +3. **Main program** (`src/main.cpp`) should: + - Call all three functions and display their results + - Demonstrate the functions work correctly + +## Testing +Your code will be automatically tested. Make sure your functions: +- Return the correct types +- Work with the expected parameters +- Produce correct results + +## Building +```bash +mkdir build +cd build +cmake .. +make +./assignment1 +``` + +## Testing +```bash +ctest +``` + +## Grading +- Code compiles without warnings: 30% +- All tests pass: 50% +- Code style and documentation: 20% \ No newline at end of file diff --git a/assignments/assignment1/include/hello.h b/assignments/assignment1/include/hello.h new file mode 100644 index 0000000..e168fd2 --- /dev/null +++ b/assignments/assignment1/include/hello.h @@ -0,0 +1,11 @@ +#pragma once +#include + +// Function to create a greeting message +std::string greet(const std::string& name); + +// Function to add two integers +int add(int a, int b); + +// Function to check if a number is even +bool isEven(int number); \ No newline at end of file diff --git a/assignments/assignment1/src/hello.cpp b/assignments/assignment1/src/hello.cpp new file mode 100644 index 0000000..1b6bce2 --- /dev/null +++ b/assignments/assignment1/src/hello.cpp @@ -0,0 +1,13 @@ +#include "hello.h" + +std::string greet(const std::string& name) { + return "Hello, " + name + "!"; +} + +int add(int a, int b) { + return a + b; +} + +bool isEven(int number) { + return number % 2 == 0; +} \ No newline at end of file diff --git a/assignments/assignment1/src/main.cpp b/assignments/assignment1/src/main.cpp new file mode 100644 index 0000000..642285a --- /dev/null +++ b/assignments/assignment1/src/main.cpp @@ -0,0 +1,29 @@ +#include +#include "hello.h" + +int main() { + // Test the greet function + std::string name = "Student"; + std::cout << greet(name) << std::endl; + + // Test the add function + int sum = add(5, 3); + std::cout << "5 + 3 = " << sum << std::endl; + + // Test the isEven function + int number = 10; + if (isEven(number)) { + std::cout << number << " is even" << std::endl; + } else { + std::cout << number << " is odd" << std::endl; + } + + number = 7; + if (isEven(number)) { + std::cout << number << " is even" << std::endl; + } else { + std::cout << number << " is odd" << std::endl; + } + + return 0; +} \ No newline at end of file diff --git a/assignments/assignment1/tests/test_hello.cpp b/assignments/assignment1/tests/test_hello.cpp new file mode 100644 index 0000000..2e53029 --- /dev/null +++ b/assignments/assignment1/tests/test_hello.cpp @@ -0,0 +1,31 @@ +#include +#include "hello.h" + +// Test the greet function +TEST(HelloTest, GreetFunction) { + EXPECT_EQ(greet("World"), "Hello, World!"); + EXPECT_EQ(greet("Student"), "Hello, Student!"); + EXPECT_EQ(greet(""), "Hello, !"); +} + +// Test the add function +TEST(HelloTest, AddFunction) { + EXPECT_EQ(add(2, 3), 5); + EXPECT_EQ(add(0, 0), 0); + EXPECT_EQ(add(-1, 1), 0); + EXPECT_EQ(add(10, 20), 30); + EXPECT_EQ(add(-5, -3), -8); +} + +// Test the isEven function +TEST(HelloTest, IsEvenFunction) { + EXPECT_TRUE(isEven(2)); + EXPECT_TRUE(isEven(0)); + EXPECT_TRUE(isEven(-2)); + EXPECT_TRUE(isEven(100)); + + EXPECT_FALSE(isEven(1)); + EXPECT_FALSE(isEven(3)); + EXPECT_FALSE(isEven(-1)); + EXPECT_FALSE(isEven(99)); +} \ No newline at end of file diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..2144345 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +# C++ Classroom Build and Test Script +# Usage: ./run_tests.sh [assignment_name] + +echo "πŸš€ C++ Classroom - Build and Test Script" +echo "========================================" + +# Change to repository root +cd "$(dirname "$0")" + +# Clean up old build if it exists +if [ -d "build" ]; then + echo "🧹 Cleaning old build directory..." + rm -rf build +fi + +# Create build directory +echo "πŸ“ Creating build directory..." +mkdir build +cd build + +# Configure with CMake +echo "βš™οΈ Configuring with CMake..." +if ! cmake ..; then + echo "❌ CMake configuration failed!" + exit 1 +fi + +# Build the project +echo "πŸ”¨ Building project..." +if ! make; then + echo "❌ Build failed!" + exit 1 +fi + +echo "βœ… Build successful!" + +# Run tests +echo "" +echo "πŸ§ͺ Running tests..." +echo "===================" + +if ! ctest --output-on-failure; then + echo "❌ Some tests failed!" + echo "" + echo "πŸ’‘ Tips:" + echo " - Check your function implementations" + echo " - Verify return types match specifications" + echo " - Test edge cases manually" + exit 1 +fi + +echo "" +echo "βœ… All tests passed!" + +# Run executables if no specific assignment specified +if [ -z "$1" ]; then + echo "" + echo "🎯 Running assignment programs..." + echo "================================" + + for assignment in assignments/*/; do + assignment_name=$(basename "$assignment") + executable="assignments/${assignment_name}/${assignment_name}" + + if [ -f "$executable" ]; then + echo "" + echo "▢️ Running ${assignment_name}:" + echo "----------------------------" + ./"$executable" + fi + done +else + # Run specific assignment + executable="assignments/$1/$1" + if [ -f "$executable" ]; then + echo "" + echo "▢️ Running $1:" + echo "----------------------------" + ./"$executable" + else + echo "❌ Assignment '$1' not found or not built!" + exit 1 + fi +fi + +echo "" +echo "πŸŽ‰ All done! Happy coding!" \ No newline at end of file diff --git a/template/CMakeLists.txt b/template/CMakeLists.txt new file mode 100644 index 0000000..f04fc94 --- /dev/null +++ b/template/CMakeLists.txt @@ -0,0 +1,33 @@ +cmake_minimum_required(VERSION 3.14) + +# Set project name - CHANGE THIS for each assignment +set(ASSIGNMENT_NAME "template") +project(${ASSIGNMENT_NAME}) + +# Include directories +include_directories(include) + +# Source files +set(SOURCES + src/main.cpp + # Add more source files here as needed +) + +# Create executable +add_executable(${ASSIGNMENT_NAME} ${SOURCES}) + +# Test files +set(TEST_SOURCES + tests/test_main.cpp + # Add source files that need to be tested (without main.cpp) + # src/your_class.cpp +) + +# Create test executable +add_executable(${ASSIGNMENT_NAME}_tests ${TEST_SOURCES}) + +# Link Google Test +target_link_libraries(${ASSIGNMENT_NAME}_tests gtest_main gtest) + +# Add test +add_test(NAME ${ASSIGNMENT_NAME}_tests COMMAND ${ASSIGNMENT_NAME}_tests) \ No newline at end of file diff --git a/template/README.md b/template/README.md new file mode 100644 index 0000000..63d40b7 --- /dev/null +++ b/template/README.md @@ -0,0 +1,31 @@ +# Assignment Template + +This is a template directory for creating new C++ programming assignments. + +## Structure + +- `src/` - Source files (.cpp) +- `include/` - Header files (.h/.hpp) +- `tests/` - Unit test files +- `CMakeLists.txt` - Build configuration +- `README.md` - Assignment instructions + +## Creating a New Assignment + +1. Copy this template directory +2. Rename to your assignment name (e.g., `assignment2`) +3. Update the CMakeLists.txt with your assignment name +4. Write your code in `src/` and headers in `include/` +5. Write tests in `tests/` +6. Update README.md with assignment instructions +7. Add the assignment to the root CMakeLists.txt + +## Building and Testing + +```bash +mkdir build +cd build +cmake .. +make +ctest +``` \ No newline at end of file diff --git a/template/src/main.cpp b/template/src/main.cpp new file mode 100644 index 0000000..904ea94 --- /dev/null +++ b/template/src/main.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + std::cout << "Hello, C++ Classroom!" << std::endl; + return 0; +} \ No newline at end of file diff --git a/template/tests/test_main.cpp b/template/tests/test_main.cpp new file mode 100644 index 0000000..9023e28 --- /dev/null +++ b/template/tests/test_main.cpp @@ -0,0 +1,14 @@ +#include + +// Example test - replace with actual tests for your assignment +TEST(TemplateTest, BasicTest) { + EXPECT_EQ(2 + 2, 4); + EXPECT_TRUE(true); +} + +TEST(TemplateTest, StringTest) { + std::string hello = "Hello"; + EXPECT_EQ(hello.length(), 5); +} + +// Add more tests here for your specific assignment requirements \ No newline at end of file