From 3f3b2ed1359a6fc7d7c896c611eca61b2001ef08 Mon Sep 17 00:00:00 2001 From: Eugene Yeboah Date: Sun, 12 Jan 2025 15:51:51 -0800 Subject: [PATCH 1/8] readme for 1st project --- iameugeneyeboah/project 1/README.md | 80 +++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 iameugeneyeboah/project 1/README.md diff --git a/iameugeneyeboah/project 1/README.md b/iameugeneyeboah/project 1/README.md new file mode 100644 index 000000000..a8f8c9196 --- /dev/null +++ b/iameugeneyeboah/project 1/README.md @@ -0,0 +1,80 @@ +# Traffic Light System Simulation + +This project simulates a traffic light system using LEDs (Arduino version) +and a console-based simulation (Python version). +The program follows a basic traffic light sequence: + +- Red light: ON for 5 seconds +- Green light: ON for 5 seconds +- Yellow light: ON for 2 seconds + +## Features + +- **Arduino Implementation**: Controls physical LEDs connected to an Arduino board. +- **Python Simulation**: Simulates the traffic light system in the console. +- **Customizable Timing**: Light durations can be adjusted. + +--- + +## Setup Instructions + +### Arduino Implementation + +1. **Hardware Requirements**: + - Arduino board + - Red, Yellow, and Green LEDs + - Resistors (220 ohms recommended) + - Breadboard and jumper wires + +2. **Circuit Diagram**: + - Connect the Red LED to pin **13** with a resistor. + - Connect the Yellow LED to pin **12** with a resistor. + - Connect the Green LED to pin **11** with a resistor. + - Connect all LED ground ends to **GND**. + +3. **Upload Code**: + - Copy the Arduino code (see `traffic_light.ino`) into the Arduino IDE. + - Connect your board and upload the code. + +### Python Simulation + +1. **Requirements**: + - Python 3.x + - No external libraries required + +2. **Run the Code**: + - Save the Python script as `traffic_light.py`. + - Run the script in your terminal using: + + ```bash + python traffic_light.py + ``` + +--- + +## Testing + +### Test Cases + +1. **Arduino Testing**: + - Verify each LED lights up at the correct time (Red → Green → Yellow). + - Test light durations by measuring the time each light stays on. + +2. **Python Testing**: + - Ensure the console outputs match the sequence and timing. + - Modify the `time.sleep()` values to confirm timing adjustments work. + +### Test Results + +| Test Scenario | Expected Behavior +|----------------------------------------|-------------------------------------- +| Arduino lights up Red → Green → Yellow | Correct sequence followed +| Timing for each light | Red: 5s, Green: 5s, Yellow: 2s +| Python simulation sequence | Console shows correct light sequence +| Console simulation timing | Red: 5s, Green: 5s, Yellow: 2s + +## Future Improvements + +- Add a pedestrian crossing button. +- Integrate a real-time clock for dynamic timing. +- Add sound effects (buzzer) during the Yellow light phase. From e3c655be29b69d1e02a88ce2a44b932feb8bfb6c Mon Sep 17 00:00:00 2001 From: Eugene Yeboah Date: Sun, 12 Jan 2025 15:56:07 -0800 Subject: [PATCH 2/8] project one codes --- iameugeneyeboah/project 1/project_one.cpp | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 iameugeneyeboah/project 1/project_one.cpp diff --git a/iameugeneyeboah/project 1/project_one.cpp b/iameugeneyeboah/project 1/project_one.cpp new file mode 100644 index 000000000..4050b7300 --- /dev/null +++ b/iameugeneyeboah/project 1/project_one.cpp @@ -0,0 +1,31 @@ +// Define LED pins +const int redLight = 13; // Red LED connected to pin 13 +const int yellowLight = 12; // Yellow LED connected to pin 12 +const int greenLight = 11; // Green LED connected to pin 11 + +void setup() { + // Set all LED pins as outputs + pinMode(redLight, OUTPUT); + pinMode(yellowLight, OUTPUT); + pinMode(greenLight, OUTPUT); +} + +void loop() { + // Turn on Red Light + digitalWrite(redLight, HIGH); + digitalWrite(yellowLight, LOW); + digitalWrite(greenLight, LOW); + delay(5000); // Wait for 5 seconds + + // Turn on Green Light + digitalWrite(redLight, LOW); + digitalWrite(yellowLight, LOW); + digitalWrite(greenLight, HIGH); + delay(5000); // Wait for 5 seconds + + // Turn on Yellow Light + digitalWrite(redLight, LOW); + digitalWrite(yellowLight, HIGH); + digitalWrite(greenLight, LOW); + delay(2000); // Wait for 2 seconds +} From e4420f2cf18a0c47017bc2fcd2669d8fbe03fff9 Mon Sep 17 00:00:00 2001 From: Eugene Yeboah Date: Sun, 12 Jan 2025 15:58:59 -0800 Subject: [PATCH 3/8] test codes --- iameugeneyeboah/project 1/test.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 iameugeneyeboah/project 1/test.cpp diff --git a/iameugeneyeboah/project 1/test.cpp b/iameugeneyeboah/project 1/test.cpp new file mode 100644 index 000000000..4c8c4995b --- /dev/null +++ b/iameugeneyeboah/project 1/test.cpp @@ -0,0 +1,29 @@ +#include +#include +#include // For delays + +using namespace std; + +void trafficLightSimulation() { + while (true) { + // Red Light + cout << "🔴 Red Light ON" << endl; + this_thread::sleep_for(chrono::seconds(5)); // Wait for 5 seconds + + // Green Light + cout << "🟢 Green Light ON" << endl; + this_thread::sleep_for(chrono::seconds(5)); // Wait for 5 seconds + + // Yellow Light + cout << "🟡 Yellow Light ON" << endl; + this_thread::sleep_for(chrono::seconds(2)); // Wait for 2 seconds + + cout << endl; // Add space before restarting the cycle + } +} + +int main() { + cout << "Starting Traffic Light Simulation..." << endl; + trafficLightSimulation(); + return 0; +} From d90fab98f13f423149f30e2b4b8634bce944937f Mon Sep 17 00:00:00 2001 From: Eugene Yeboah Date: Sun, 12 Jan 2025 16:30:45 -0800 Subject: [PATCH 4/8] readme for project 2 --- iameugeneyeboah/project 2/README.md | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 iameugeneyeboah/project 2/README.md diff --git a/iameugeneyeboah/project 2/README.md b/iameugeneyeboah/project 2/README.md new file mode 100644 index 000000000..37ca31af3 --- /dev/null +++ b/iameugeneyeboah/project 2/README.md @@ -0,0 +1,41 @@ +# Photography Portfolio Management System + +## Overview + +This system allows photographers to manage their photography portfolio. +Users can upload photos, categorize them, add metadata, search, +and manage the portfolio by editing or deleting photos. + +## Features + +1. **Upload Photos**: Upload photos with metadata (title, description, and date taken). +2. **Search Photos**: Search photos by category, date range, or keywords. +3. **Edit Metadata**: Edit photo metadata like title and description. +4. **View Portfolio**: Display a list of all photos in the portfolio with their metadata. +5. **Delete Photos**: Delete a photo from the portfolio. +6. **Save Portfolio**: Save the portfolio data to a file for persistence. + +## Technologies + +- Python 3.x +- JSON (or CSV) for storing the portfolio data. + +## Setup + +1. Clone or download the repository. +2. Install Python 3.x. +3. Run the program using a Python interpreter. + +## Usage + +To use the system, run the `portfolio_manager.py` script. +Follow the command-line prompts to: + +- Add, edit, delete, or search photos. +- View the entire portfolio. +- Save and load the portfolio data from a file. + +## Testing + +- Unit tests are provided in the `test_portfolio.py` file to ensure +- the functionality of the core features. From cef631fe12ba02b06838fe81fc9567d790c7b630 Mon Sep 17 00:00:00 2001 From: Eugene Yeboah Date: Sun, 12 Jan 2025 16:33:50 -0800 Subject: [PATCH 5/8] code for project 2 --- .../project 2/portfolio_manager.py | 168 ++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 iameugeneyeboah/project 2/portfolio_manager.py diff --git a/iameugeneyeboah/project 2/portfolio_manager.py b/iameugeneyeboah/project 2/portfolio_manager.py new file mode 100644 index 000000000..ba3b98fe1 --- /dev/null +++ b/iameugeneyeboah/project 2/portfolio_manager.py @@ -0,0 +1,168 @@ +import json +import os +from datetime import datetime + + +class Photo: + def __init__(self, title, description, category, date_taken): + self.title = title + self.description = description + self.category = category + self.date_taken = date_taken + + def to_dict(self): + return { + "title": self.title, + "description": self.description, + "category": self.category, + "date_taken": self.date_taken, + } + + @staticmethod + def from_dict(photo_dict): + return Photo( + photo_dict["title"], + photo_dict["description"], + photo_dict["category"], + photo_dict["date_taken"], + ) + + +class PortfolioManager: + def __init__(self, file_name="portfolio.json"): + self.file_name = file_name + self.photos = self.load_portfolio() + + def load_portfolio(self): + if os.path.exists(self.file_name): + with open(self.file_name, "r") as file: + data = json.load(file) + return [Photo.from_dict(photo) for photo in data] + return [] + + def save_portfolio(self): + with open(self.file_name, "w") as file: + data = [photo.to_dict() for photo in self.photos] + json.dump(data, file) + + def add_photo(self, title, description, category, date_taken): + new_photo = Photo(title, description, category, date_taken) + self.photos.append(new_photo) + self.save_portfolio() + + def search_photos(self, category=None, date_range=None, keyword=None): + results = self.photos + if category: + results = [ + photo for photo in results if photo.category.lower() == category.lower() + ] + if date_range: + start_date, end_date = date_range + results = [ + photo + for photo in results + if start_date + <= datetime.strptime(photo.date_taken, "%Y-%m-%d") + <= end_date + ] + if keyword: + results = [ + photo + for photo in results + if keyword.lower() in photo.title.lower() + or keyword.lower() in photo.description.lower() + ] + return results + + def edit_metadata(self, title, new_title=None, new_description=None): + for photo in self.photos: + if photo.title == title: + if new_title: + photo.title = new_title + if new_description: + photo.description = new_description + self.save_portfolio() + return photo + return None + + def delete_photo(self, title): + self.photos = [photo for photo in self.photos if photo.title != title] + self.save_portfolio() + + def view_portfolio(self): + return self.photos + + +def print_photo_details(photos): + for photo in photos: + print(f"Title: {photo.title}") + print(f"Category: {photo.category}") + print(f"Description: {photo.description}") + print(f"Date Taken: {photo.date_taken}") + print("-" * 30) + + +def main(): + portfolio = PortfolioManager() + + while True: + print("\n1. Add Photo") + print("2. Search Photos") + print("3. Edit Metadata") + print("4. Delete Photo") + print("5. View Portfolio") + print("6. Exit") + + choice = input("Enter your choice: ") + + if choice == "1": + title = input("Enter title: ") + description = input("Enter description: ") + category = input("Enter category: ") + date_taken = input("Enter date taken (YYYY-MM-DD): ") + portfolio.add_photo(title, description, category, date_taken) + elif choice == "2": + category = input("Enter category to search (or press Enter to skip): ") + date_range_input = input( + "Enter date range (YYYY-MM-DD to YYYY-MM-DD) or press Enter to skip: " + ) + keyword = input( + "Enter keyword to search for in title/description or press Enter to skip: " + ) + + date_range = None + if date_range_input: + start_date, end_date = date_range_input.split(" to ") + date_range = ( + datetime.strptime(start_date, "%Y-%m-%d"), + datetime.strptime(end_date, "%Y-%m-%d"), + ) + + results = portfolio.search_photos( + category=category, date_range=date_range, keyword=keyword + ) + print_photo_details(results) + elif choice == "3": + title = input("Enter title of the photo to edit: ") + new_title = input("Enter new title (or press Enter to skip): ") + new_description = input("Enter new description (or press Enter to skip): ") + updated_photo = portfolio.edit_metadata(title, new_title, new_description) + if updated_photo: + print(f"Updated: {updated_photo.title}") + else: + print("Photo not found.") + elif choice == "4": + title = input("Enter title of the photo to delete: ") + portfolio.delete_photo(title) + print("Photo deleted.") + elif choice == "5": + photos = portfolio.view_portfolio() + print_photo_details(photos) + elif choice == "6": + break + else: + print("Invalid choice, please try again.") + + +if __name__ == "__main__": + main() From 4c6e015f8229b7049127c998f87862d8780d499d Mon Sep 17 00:00:00 2001 From: Eugene Yeboah Date: Sun, 12 Jan 2025 17:07:19 -0800 Subject: [PATCH 6/8] change name --- iameugeneyeboah/{project 2 => challenge_two}/README.md | 0 iameugeneyeboah/{project 2 => challenge_two}/portfolio_manager.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename iameugeneyeboah/{project 2 => challenge_two}/README.md (100%) rename iameugeneyeboah/{project 2 => challenge_two}/portfolio_manager.py (100%) diff --git a/iameugeneyeboah/project 2/README.md b/iameugeneyeboah/challenge_two/README.md similarity index 100% rename from iameugeneyeboah/project 2/README.md rename to iameugeneyeboah/challenge_two/README.md diff --git a/iameugeneyeboah/project 2/portfolio_manager.py b/iameugeneyeboah/challenge_two/portfolio_manager.py similarity index 100% rename from iameugeneyeboah/project 2/portfolio_manager.py rename to iameugeneyeboah/challenge_two/portfolio_manager.py From da5e22def3a1a32036ca96de11c75aa534c00f6f Mon Sep 17 00:00:00 2001 From: Eugene Yeboah Date: Sun, 12 Jan 2025 17:13:27 -0800 Subject: [PATCH 7/8] changes to readme --- .../{project 1 => challenge_one}/README.md | 0 .../project_one.cpp | 0 .../{project 1 => challenge_one}/test.cpp | 0 iameugeneyeboah/challenge_two/README.md | 37 ++++++++----------- 4 files changed, 15 insertions(+), 22 deletions(-) rename iameugeneyeboah/{project 1 => challenge_one}/README.md (100%) rename iameugeneyeboah/{project 1 => challenge_one}/project_one.cpp (100%) rename iameugeneyeboah/{project 1 => challenge_one}/test.cpp (100%) diff --git a/iameugeneyeboah/project 1/README.md b/iameugeneyeboah/challenge_one/README.md similarity index 100% rename from iameugeneyeboah/project 1/README.md rename to iameugeneyeboah/challenge_one/README.md diff --git a/iameugeneyeboah/project 1/project_one.cpp b/iameugeneyeboah/challenge_one/project_one.cpp similarity index 100% rename from iameugeneyeboah/project 1/project_one.cpp rename to iameugeneyeboah/challenge_one/project_one.cpp diff --git a/iameugeneyeboah/project 1/test.cpp b/iameugeneyeboah/challenge_one/test.cpp similarity index 100% rename from iameugeneyeboah/project 1/test.cpp rename to iameugeneyeboah/challenge_one/test.cpp diff --git a/iameugeneyeboah/challenge_two/README.md b/iameugeneyeboah/challenge_two/README.md index 37ca31af3..ace780658 100644 --- a/iameugeneyeboah/challenge_two/README.md +++ b/iameugeneyeboah/challenge_two/README.md @@ -1,41 +1,34 @@ -# Photography Portfolio Management System +# To-Do List App ## Overview -This system allows photographers to manage their photography portfolio. -Users can upload photos, categorize them, add metadata, search, -and manage the portfolio by editing or deleting photos. +This is a simple To-Do List application built in Python. +The program allows users to add, view, and delete tasks from a to-do list. +The list of tasks is saved to a file (`todo.txt`) +so that the tasks persist across program runs. ## Features -1. **Upload Photos**: Upload photos with metadata (title, description, and date taken). -2. **Search Photos**: Search photos by category, date range, or keywords. -3. **Edit Metadata**: Edit photo metadata like title and description. -4. **View Portfolio**: Display a list of all photos in the portfolio with their metadata. -5. **Delete Photos**: Delete a photo from the portfolio. -6. **Save Portfolio**: Save the portfolio data to a file for persistence. +1. **Add Task**: Allows the user to add a task with a description. +2. **View Tasks**: Displays all tasks in the to-do list. +3. **Delete Task**: Allows the user to delete a task by specifying its task number. +4. **Persist Data**: The tasks are saved in a file (`todo.txt`) +5. and are reloaded when the program restarts. ## Technologies - Python 3.x -- JSON (or CSV) for storing the portfolio data. +- File handling (Text file for storing tasks) ## Setup 1. Clone or download the repository. -2. Install Python 3.x. +2. Ensure Python 3.x is installed. 3. Run the program using a Python interpreter. ## Usage -To use the system, run the `portfolio_manager.py` script. -Follow the command-line prompts to: +- Run the program using the following command: -- Add, edit, delete, or search photos. -- View the entire portfolio. -- Save and load the portfolio data from a file. - -## Testing - -- Unit tests are provided in the `test_portfolio.py` file to ensure -- the functionality of the core features. + ```bash + python todo_list.py From 847c05a357a7c2326e62e6b78b0ecdecea06027b Mon Sep 17 00:00:00 2001 From: Eugene Yeboah Date: Sun, 12 Jan 2025 17:15:45 -0800 Subject: [PATCH 8/8] edited --- .../challenge_two/portfolio_manager.py | 215 +++++------------- 1 file changed, 58 insertions(+), 157 deletions(-) diff --git a/iameugeneyeboah/challenge_two/portfolio_manager.py b/iameugeneyeboah/challenge_two/portfolio_manager.py index ba3b98fe1..46ff81c66 100644 --- a/iameugeneyeboah/challenge_two/portfolio_manager.py +++ b/iameugeneyeboah/challenge_two/portfolio_manager.py @@ -1,168 +1,69 @@ -import json -import os -from datetime import datetime - - -class Photo: - def __init__(self, title, description, category, date_taken): - self.title = title - self.description = description - self.category = category - self.date_taken = date_taken - - def to_dict(self): - return { - "title": self.title, - "description": self.description, - "category": self.category, - "date_taken": self.date_taken, - } - - @staticmethod - def from_dict(photo_dict): - return Photo( - photo_dict["title"], - photo_dict["description"], - photo_dict["category"], - photo_dict["date_taken"], - ) - - -class PortfolioManager: - def __init__(self, file_name="portfolio.json"): - self.file_name = file_name - self.photos = self.load_portfolio() - - def load_portfolio(self): - if os.path.exists(self.file_name): - with open(self.file_name, "r") as file: - data = json.load(file) - return [Photo.from_dict(photo) for photo in data] +def load_tasks(filename="todo.txt"): + """Load tasks from a file.""" + try: + with open(filename, "r") as file: + tasks = file.readlines() + return [task.strip() for task in tasks] + except FileNotFoundError: return [] - def save_portfolio(self): - with open(self.file_name, "w") as file: - data = [photo.to_dict() for photo in self.photos] - json.dump(data, file) - - def add_photo(self, title, description, category, date_taken): - new_photo = Photo(title, description, category, date_taken) - self.photos.append(new_photo) - self.save_portfolio() - - def search_photos(self, category=None, date_range=None, keyword=None): - results = self.photos - if category: - results = [ - photo for photo in results if photo.category.lower() == category.lower() - ] - if date_range: - start_date, end_date = date_range - results = [ - photo - for photo in results - if start_date - <= datetime.strptime(photo.date_taken, "%Y-%m-%d") - <= end_date - ] - if keyword: - results = [ - photo - for photo in results - if keyword.lower() in photo.title.lower() - or keyword.lower() in photo.description.lower() - ] - return results - - def edit_metadata(self, title, new_title=None, new_description=None): - for photo in self.photos: - if photo.title == title: - if new_title: - photo.title = new_title - if new_description: - photo.description = new_description - self.save_portfolio() - return photo - return None - - def delete_photo(self, title): - self.photos = [photo for photo in self.photos if photo.title != title] - self.save_portfolio() - - def view_portfolio(self): - return self.photos - - -def print_photo_details(photos): - for photo in photos: - print(f"Title: {photo.title}") - print(f"Category: {photo.category}") - print(f"Description: {photo.description}") - print(f"Date Taken: {photo.date_taken}") - print("-" * 30) - +def save_tasks(tasks, filename="todo.txt"): + """Save tasks to a file.""" + with open(filename, "w") as file: + for task in tasks: + file.write(task + "\n") + +def add_task(tasks): + """Add a new task to the list.""" + task = input("Enter the task description: ") + tasks.append(task) + save_tasks(tasks) + +def view_tasks(tasks): + """Display all tasks.""" + if tasks: + print("\nTo-Do List:") + for idx, task in enumerate(tasks, start=1): + print(f"{idx}. {task}") + else: + print("\nYour to-do list is empty.") + +def delete_task(tasks): + """Delete a task from the list.""" + try: + task_num = int(input("Enter the task number to delete: ")) + if 1 <= task_num <= len(tasks): + tasks.pop(task_num - 1) + save_tasks(tasks) + print("Task deleted successfully.") + else: + print("Invalid task number.") + except ValueError: + print("Please enter a valid number.") def main(): - portfolio = PortfolioManager() + tasks = load_tasks() while True: - print("\n1. Add Photo") - print("2. Search Photos") - print("3. Edit Metadata") - print("4. Delete Photo") - print("5. View Portfolio") - print("6. Exit") - - choice = input("Enter your choice: ") - - if choice == "1": - title = input("Enter title: ") - description = input("Enter description: ") - category = input("Enter category: ") - date_taken = input("Enter date taken (YYYY-MM-DD): ") - portfolio.add_photo(title, description, category, date_taken) - elif choice == "2": - category = input("Enter category to search (or press Enter to skip): ") - date_range_input = input( - "Enter date range (YYYY-MM-DD to YYYY-MM-DD) or press Enter to skip: " - ) - keyword = input( - "Enter keyword to search for in title/description or press Enter to skip: " - ) - - date_range = None - if date_range_input: - start_date, end_date = date_range_input.split(" to ") - date_range = ( - datetime.strptime(start_date, "%Y-%m-%d"), - datetime.strptime(end_date, "%Y-%m-%d"), - ) - - results = portfolio.search_photos( - category=category, date_range=date_range, keyword=keyword - ) - print_photo_details(results) - elif choice == "3": - title = input("Enter title of the photo to edit: ") - new_title = input("Enter new title (or press Enter to skip): ") - new_description = input("Enter new description (or press Enter to skip): ") - updated_photo = portfolio.edit_metadata(title, new_title, new_description) - if updated_photo: - print(f"Updated: {updated_photo.title}") - else: - print("Photo not found.") - elif choice == "4": - title = input("Enter title of the photo to delete: ") - portfolio.delete_photo(title) - print("Photo deleted.") - elif choice == "5": - photos = portfolio.view_portfolio() - print_photo_details(photos) - elif choice == "6": + print("\nTo-Do List Menu:") + print("1. Add Task") + print("2. View Tasks") + print("3. Delete Task") + print("4. Exit") + + choice = input("Choose an option: ") + + if choice == '1': + add_task(tasks) + elif choice == '2': + view_tasks(tasks) + elif choice == '3': + delete_task(tasks) + elif choice == '4': + print("Goodbye!") break else: - print("Invalid choice, please try again.") - + print("Invalid choice. Please try again.") if __name__ == "__main__": main()