Initial commit

This commit is contained in:
lev
2026-05-28 12:40:04 +00:00
commit 82cd53270d
35 changed files with 616 additions and 0 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}

329
README.md Normal file
View File

@@ -0,0 +1,329 @@
# Git-Scavenger-Hunt
# 🎯 Git Scavenger Hunt - Activity Guide
## Overview
Get set for some real Git action! This scavenger hunt will take you on an adventure through the wilds of branches, uncover the secrets of commits, and delve into the mysteries of pull requests and code reviews.
Whether you're eyeing a career as a software engineer, want to contribute to open-source projects, or just love learning new skills, knowing your way around a version control platform like Gitea is a game-changer.
---
## 📋 Prerequisites
Before you start, make sure Git is installed on your computer:
### Installation
**Windows (PowerShell/CMD):**
- Download from [git-scm.com](https://git-scm.com)
**Mac (Terminal):**
```bash
git --version
```
If not installed, it will prompt you to install Xcode Command Line Tools.
**Linux (Terminal):**
```bash
# Ubuntu/Debian
sudo apt install git
# Fedora
sudo dnf install git
```
### Verify Installation
```bash
git --version
```
---
## 🚀 Getting Started
### Step 1: Create Repository
**Partner A:**
1. Navigate to the template repo: https://gitea.techshare.cc/admin/Git-Scavenger-Hunt.git
2. Use it to create a new repository for your team (look for "Use this template" or "Fork")
3. On the "Create a new repository" page:
- Select your account/owner
- Enter a name for the repository
- Click the button to create it
### Step 2: Add Collaborator
**Partner A:**
1. Go to the **Settings** tab or "Repository Settings"
2. Navigate to **Collaborators** or **Collaboration**
3. Search for your partner's Gitea username and add them
**Partner B:**
1. Click your profile icon in the top-right corner
2. Go to your notification settings or check for pending invitations
3. Accept the invitation to join your partner's repo
### Step 3: Clone Repository
From the main page of your new repository, copy the HTTPS clone link.
**Both Partners:**
```bash
# Navigate to where you want to store the project
cd ~/Desktop
# or any folder you prefer
# Clone the repository
git clone <paste-the-https-link-you-copied>
# Enter the cloned directory
cd <your-repository-name>
# Verify the clone worked
ls # Mac/Linux
dir # Windows PowerShell
# Check Git status
git status # Shows you're on the main branch
```
---
## 🌿 Part 1: Creating Branches
### What is a Branch?
A **repository** (or "repo") is like a project's folder and contains all the project files and each file's revision history. Repositories can have multiple collaborators and can be either public or private.
A **branch** is a separate line of development. You can use branches to isolate your work when you're developing a new feature or fixing a bug.
### Create Your Branches
**Partner A (in your terminal):**
```bash
# Create a new branch (replace 'your-branch-name' with something descriptive)
git checkout -b feature/add-student-method
# Verify you are on the new branch
git branch
# Push the new branch to the remote repository (Gitea)
git push -u origin feature/add-student-method
```
**Partner B (in your terminal):**
```bash
# First, pull the latest changes to see the new branch
git fetch
# Create your own branch
git checkout -b bugfix/fix-syntax-error
# Push your branch to the remote
git push -u origin bugfix/fix-syntax-error
```
### 💡 Branch Naming Best Practices
Branch names help your team understand what is being worked on:
-**Keep it short:** Branch names should be concise
-**Use dashes or slashes:** Separate words with dashes (`my-new-feature`) or slashes (`feature/my-new-feature`)
-**Use lowercase:** It's best to stick to lowercase, as Git is case-sensitive
-**Describe the work:** The name should give an idea of what the changes involve
**Examples:**
- `feature/user-authentication`
- `bugfix/login-error`
- `docs/update-readme`
- `refactor/cleanup-code`
---
## ✏️ Part 2: Making Changes
Work together on **Partner B's computer** to make the following changes.
### Delete a File
```bash
# Find and delete the file (e.g., DeleteMe.java)
rm DeleteMe.java # Mac/Linux
del DeleteMe.java # Windows PowerShell
# Check Git status to see what changed
git status
```
You should see the deleted file listed as a change.
### Stage and Commit the Change
```bash
# Stage the deletion (tell Git which changes to track)
git add DeleteMe.java
# Commit the change with a message
git commit -m "removed unused DeleteMe.java file"
# Push the commit to the remote repository
git push
```
### 💡 Understanding Git States
A **commit** is an individual change to a file (or set of files). With Git, there are three key states that a file can be in:
1. **Modified:** The file has been changed, but Git is not tracking these changes yet
2. **Staged** (`git add`): The changes you made are exactly what you want to include in the next commit
3. **Committed** (`git commit`): The version of the file has been safely saved in your local repo
### Fix a Syntax Error
Back in the code... There is a syntax error in one of the existing `.java` files. Find the error and fix it using any text editor (VS Code, Notepad++, nano, vim, etc.).
```bash
# See which file changed
git status
# Stage the fixed file
git add <filename>.java
# Commit your fix
git commit -m "fixed syntax error in Student class"
# Push to remote
git push
```
### Explore Your Repository
Go to the repo on the **Gitea web interface**. Can you find your branches?
💡 **Hint:** Look for a dropdown on the main page of the repo that says `main`. Click it to see the list of branches.
---
## 🛑 Part 3: Stop & Reflect 🤔
Answer these questions in your notes or with your partner:
1. **Why do you think it's important to create a new branch when making changes to the code, rather than making changes directly in the main branch?**
2. **What does it mean to push your changes, and why is this an important step in using a version control system like Git?**
---
## 🔀 Part 4: Open a Pull Request
### What is a Pull Request?
A **Pull Request** (sometimes called a Merge Request) is a method of submitting contributions to a project. It lets you notify others about changes you've pushed to a repository on Gitea.
### Partner B: Create Pull Request
1. Navigate to the repo on the Gitea web interface
2. Go to the **Pull Requests** tab
3. Click the **New Pull Request** button
4. Make sure you're merging to the correct branch:
- **Base:** Partner A's branch
- **Compare:** Your branch
5. Provide a title and a brief description for your pull request
6. Select **Partner A** as a reviewer
### Partner A: Create Pull Request
Now follow the same process to open a pull request to merge your branch into the `main` branch:
1. Provide a title and a description
2. Select **Partner B** as the reviewer
---
## 👀 Part 5: Reviewing the PR
### Review Your Partner's Work
1. Go to the **Pull Requests** tab in the Gitea web interface
2. Select your partner's pull request from the list
3. Click the **Files Changed** tab
4. Go through the changes line by line
5. For each change, click on the line number to add a comment about that specific line
### Submit Your Review
When you're done reviewing:
1. Write a **summary comment** to give overall feedback about the changes
2. If you've found issues that need to be addressed, submit your review with a **request for changes**
3. If everything looks good, **approve** the pull request
4. On the **Conversation** tab, click the green button to **merge** the pull request
5. Click the **Delete branch** button after the merge is complete
### 💡 Why Delete Branches?
It is often recommended to delete the branch after merging. Branches are typically short-lived and topic-specific, so they aren't needed anymore once the work is merged.
---
## 🛑 Part 6: Stop & Reflect 🤔
Answer these questions in your notes or with your partner:
1. **Explain in your own words what a pull request is and why it's useful when collaborating on a codebase.**
2. **How did it feel to receive feedback on your own code? How can you use this feedback to improve your coding skills?**
---
## 📚 Bonus: Quick Git Commands Reference
| Command | Description |
|---------|-------------|
| `git clone <url>` | Download a repository to your computer |
| `git branch` | List all branches |
| `git checkout -b <name>` | Create and switch to a new branch |
| `git checkout <name>` | Switch to an existing branch |
| `git status` | See what files have changed |
| `git add <file>` | Stage a file for commit |
| `git add .` | Stage all changed files |
| `git commit -m "message"` | Commit staged changes |
| `git push` | Push commits to remote repository |
| `git pull` | Pull latest changes from remote |
| `git fetch` | Download remote changes without merging |
| `git log --oneline` | View commit history |
---
## 🎓 Learning Outcomes
By completing this scavenger hunt, you will:
- ✅ Understand how to create and manage branches
- ✅ Learn the Git workflow: modify → stage → commit → push
- ✅ Practice collaboration through pull requests and code reviews
- ✅ Gain hands-on experience with Gitea (or similar platforms like GitHub/GitLab)
- ✅ Develop best practices for version control in team environments
---
## 💡 Tips for Success
1. **Communicate with your partner** - Discuss your changes before committing
2. **Write clear commit messages** - Explain what changed and why
3. **Review code thoroughly** - Look for bugs, style issues, and improvements
4. **Be constructive with feedback** - Focus on the code, not the person
5. **Ask questions** - If something doesn't make sense, ask for clarification
---
## 🔗 Additional Resources
- [Git Official Documentation](https://git-scm.com/doc)
- [Pro Git Book](https://git-scm.com/book/en/v2)
---
**Happy Coding! 🚀**

BIN
assets/lesson1-01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
assets/lesson1-02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
assets/lesson1-03.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
assets/lesson1-04.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

BIN
assets/lesson1-05.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
assets/lesson1-06.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
assets/lesson1-07.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

BIN
assets/lesson1-08.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
assets/lesson1-09.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
assets/lesson1-10.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
assets/lesson1-11.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
assets/lesson1-12.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
assets/lesson1-13.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
assets/lesson1-14.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
assets/lesson1-15.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

BIN
assets/lesson1-16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
assets/lesson1-17.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
assets/lesson1-18.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

75
pom.xml Normal file
View File

@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.csase</groupId>
<artifactId>githubintro</artifactId>
<version>1.0</version>
<name>githubintro</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.9.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!--
https://projectlombok.org/
-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<!--
https://junit.org/junit5/docs/current/user-guide/#writing-tests-parameterized-tests
-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<!-- remove spaces
<compilerArgs> - - enable-preview</compilerArgs>
-->
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
</plugins>
</build>
</project>

BIN
src/.DS_Store vendored Normal file

Binary file not shown.

BIN
src/main/.DS_Store vendored Normal file

Binary file not shown.

BIN
src/main/java/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,57 @@
package com.csase;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/*
* Represents an assignment with a name and due date
*/
public class Assignment {
private String name; // name of assignment
private LocalDate dueDate; // due date of assignment
/*
* Sets name and due date of assignment
*/
public Assignment(String name, LocalDate dueDate) {
this.name = name;
this.dueDate = dueDate;
}
/*
* Returns name of assignment
*/
public String getName() {
return this.name;
}
/*
* Returns due date of assignment
*/
public LocalDate getDueDate() {
return this.dueDate;
}
/*
* Sets name of assignment
*/
public void setName(String name) {
this.name = name;
}
/*
* Sets due date of assignment
*/
public void setDate(LocalDate dueDate) {
this.dueDate = dueDate;
}
/*
* Returns string representation of assignment
*/
public String toString() {
return this.name + " (due: " + this.dueDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy")) + ")";
}
}

View File

@@ -0,0 +1,9 @@
package com.csase;
public class DeleteMe {
public void deleteMe() {
System.out.println("Delete me!");
}
}

View File

@@ -0,0 +1,13 @@
package com.csase;
public class PlannerRunner {
public static void main(String[] args) {
// Create a new student
Student jada = new Student();
// Gets the student's choice until the student exits
jada.getChoice();
}
}

View File

@@ -0,0 +1,63 @@
package com.csase;
import java.util.Scanner;
/*
* Represents a student that with a study planner
*/
public class Student {
private StudyPlanner planner; // study planner
private Scanner scanner; // scanner for user input
/*
* Sets study planner and scanner
*/
public Student {
planner = new StudyPlanner();
scanner = new Scanner(System.in);
}
/*
* Gets the student's choice and runs it until the student exits
*/
public void getChoice() {
int option = -1;
while (option != 3) {
System.out.println("Welcome to Study Planner!");
System.out.println("What would you like to do?");
System.out.println(planner.getOptions());
System.out.print("Enter option: ");
option = scanner.nextInt();
scanner.nextLine();
runChoice(option);
}
}
/*
* Runs the student's choice
*/
public void runChoice(int option) {
if (option == 1) {
addAssignment();
} else if (option == 2) {
System.out.println(planner.listAssignments());
} else if (option == 3) {
System.out.println("Goodbye!");
} else {
System.out.println("Invalid option!");
}
}
/*
* Adds a new assignment to the study planner
*/
public void addAssignment() {
System.out.print("Enter assignment name: ");
String name = scanner.nextLine();
System.out.print("Enter due date (YYYY-MM-DD): ");
String dueDate = scanner.nextLine();
planner.addAssignment(name, dueDate);
}
}

View File

@@ -0,0 +1,67 @@
package com.csase;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
/*
* Represents a study planner with a list of assignments
*/
public class StudyPlanner {
private ArrayList<Assignment> assignments; // list of assignments
private String[] options; // list of options
/*
* Sets assignments and options
*/
public StudyPlanner() {
assignments = new ArrayList<Assignment>();
options = new String[]{"1. Add Assignment", "2. List Assignments", "3. Exit"};
}
/*
* Returns list of assignments
*/
public ArrayList<Assignment> getAssignments() {
return assignments;
}
/*
* Adds a new assignment to the list of assignments
*/
public void addAssignment(String name, String dueDateString) {
LocalDate dueDate = LocalDate.parse(dueDateString, DateTimeFormatter.ISO_LOCAL_DATE);
assignments.add(new Assignment(name, dueDate));
}
/*
* Returns string representation of assignments
*/
public String listAssignments() {
String assignmentsString = "";
if (assignments.size() == 0) {
return "No assignments to list!\n";
}
for (Assignment assignment : assignments) {
assignmentsString += assignment.toString() + "\n";
}
return assignmentsString;
}
/*
* Returns string representation of options
*/
public String getOptions() {
String optionsString = "";
for (String option : options) {
optionsString += option + "\n";
}
return optionsString;
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.