diff --git a/Domains/CompetitiveProgramming/Programs/Python/Tic Tac Toe/README.md b/Domains/CompetitiveProgramming/Programs/Python/Tic Tac Toe/README.md new file mode 100644 index 00000000..05e621d2 --- /dev/null +++ b/Domains/CompetitiveProgramming/Programs/Python/Tic Tac Toe/README.md @@ -0,0 +1,19 @@ +**Contributor:** GayatriVitkar + +# Tic Tac Toe Game ๐ฎ + +A simple Tic Tac Toe game built in Python allowing two players to play locally in the console. + +## Features +- Two-player gameplay +- Clear console interface +- Option to restart the game after finishing + +## How to Play +1. Run the Python script: `python tictactoe.py` +2. Player X starts and chooses a position (1-9). +3. Player O plays next. +4. The game continues until one player wins or the board is full. + +## Contributing +Feel free to improve the game or add new features! diff --git a/Domains/CompetitiveProgramming/Programs/Python/Tic Tac Toe/Tictactoe.py b/Domains/CompetitiveProgramming/Programs/Python/Tic Tac Toe/Tictactoe.py new file mode 100644 index 00000000..485817e1 --- /dev/null +++ b/Domains/CompetitiveProgramming/Programs/Python/Tic Tac Toe/Tictactoe.py @@ -0,0 +1,95 @@ +import tkinter as tk +from tkinter import messagebox + +class TicTacToe: + def __init__(self, root): + # Initialize the main application window + self.root = root + self.root.title("Tic Tac Toe") + + # Set the current player and initialize the board state + self.current_player = "X" + self.board = [""] * 9 + + # List to hold button references for the game board + self.buttons = [] + self.create_board() + + def create_board(self): + # Create a frame to hold the game board buttons + frame = tk.Frame(self.root, bg="lightblue") # Add background color for aesthetic + frame.pack(padx=10, pady=10) + + # Create 9 buttons (3x3 grid) for the board + for i in range(9): + button = tk.Button( + frame, text="", font=("Arial", 24, "bold"), width=5, height=2, + bg="white", fg="black", command=lambda i=i: self.on_click(i), relief="raised" # Pass button index to the click handler + ) + button.grid(row=i//3, column=i%3, padx=5, pady=5) # Position button in the grid + self.buttons.append(button) + + # Add a label to display the current player's turn + self.turn_label = tk.Label( + self.root, text=f"Player {self.current_player}'s Turn", font=("Arial", 16), bg="lightblue" + ) + self.turn_label.pack(pady=5) + + # Add a restart button below the game board + self.restart_button = tk.Button( + self.root, text="Restart Game", font=("Arial", 14, "bold"), bg="orange", fg="white", + command=self.restart_game + ) + self.restart_button.pack(pady=10) + + def on_click(self, index): + # Handle a button click event + if self.board[index] == "": # Ensure the button has not already been clicked + self.board[index] = self.current_player + self.buttons[index].config(text=self.current_player, fg="blue" if self.current_player == "X" else "red") # Update button text + + if self.check_winner(): # Check if the current player has won + messagebox.showinfo("Game Over", f"Player {self.current_player} wins!") + self.turn_label.config(text=f"Player {self.current_player} wins!") + self.disable_buttons() # Disable further interaction with the board + elif "" not in self.board: # Check for a draw condition + messagebox.showinfo("Game Over", "It's a draw!") + self.turn_label.config(text="It's a draw!") + else: + # Switch to the other player + self.current_player = "O" if self.current_player == "X" else "X" + self.turn_label.config(text=f"Player {self.current_player}'s Turn") + + def check_winner(self): + # Define winning patterns (rows, columns, diagonals) + win_patterns = [ + [0, 1, 2], [3, 4, 5], [6, 7, 8], # Rows + [0, 3, 6], [1, 4, 7], [2, 5, 8], # Columns + [0, 4, 8], [2, 4, 6] # Diagonals + ] + + # Check if any winning pattern is satisfied + for pattern in win_patterns: + if self.board[pattern[0]] == self.board[pattern[1]] == self.board[pattern[2]] != "": + return True + return False + + def disable_buttons(self): + # Disable all buttons to prevent further interaction + for button in self.buttons: + button.config(state="disabled") + + def restart_game(self): + # Reset the game to its initial state + self.current_player = "X" # Reset to player X + self.board = [""] * 9 # Clear the board state + self.turn_label.config(text=f"Player {self.current_player}'s Turn") # Update turn label + for button in self.buttons: + button.config(text="", state="normal", bg="white") # Clear button text and enable them + +if __name__ == "__main__": + # Create the main application window and run the game + root = tk.Tk() + root.configure(bg="lightblue") # Set a background color for the main window + game = TicTacToe(root) + root.mainloop() diff --git a/Domains/Frontend/MiniProjects/NewsFlash/README.md b/Domains/Frontend/MiniProjects/NewsFlash/README.md new file mode 100644 index 00000000..684a8570 --- /dev/null +++ b/Domains/Frontend/MiniProjects/NewsFlash/README.md @@ -0,0 +1,104 @@ +**Contributor:** GayatriVitkarcd + +๐ Description + +NewsFlash is a responsive and modern web application that delivers the latest news headlines from multiple categories in real-time using the NewsAPI. + +The project has a clean glassmorphism-inspired interface with smooth hover effects, animated loading transitions, and a seamless infinite scroll experience. +Users can explore top news, search for specific topics, and filter articles by categories like Technology, Sports, Business, Entertainment, and more. + +Each news card contains a thumbnail, headline, short description, source, and a โRead Moreโ button that opens the full article in a new tab. + +๐ฏ Features + +๐ Live News Fetching: Displays updated news headlines using NewsAPI. + +๐ Search Functionality: Find news instantly by typing keywords. + +๐ท๏ธ Category Filters: Switch easily between trending topics. + +โพ๏ธ Infinite Scroll: Automatically loads more news as you scroll. + +๐ Responsive Glassmorphism UI: Works smoothly on all screen sizes. + +โก Fast & Lightweight: Built using pure HTML, CSS, and vanilla JavaScript. + +๐ ๏ธ Tech Stack + +HTML5: Structure and layout of the web pages. + +CSS3: Custom responsive design with glassmorphism and animations. + +JavaScript (Fetch API): Fetches and dynamically displays live news content. + +๐ How to Run +๐ฅ๏ธ Method 1: Open in Browser + +Download or clone this repository. + +Open index.html directly in your browser. + +โก Method 2: Live Server (Recommended) + +Open project in VS Code. + +Right-click index.html โ Open with Live Server. + +App runs locally at http://localhost:5500. + +๐ Project Structure +NewsFlash/ +โโโ index.html # Main HTML file +โโโ style.css # Styling and layout +โโโ script.js # JavaScript logic and API integration +โโโ README.md # Documentation +โโโ assets/ # Images or icons used + +๐ Learning Outcomes + +Working with public APIs (NewsAPI) + +Asynchronous JavaScript (Fetch, async/await) + +DOM Manipulation and Dynamic Rendering + +Responsive UI Design + +Event Handling and Search Filtering + +Implementing Infinite Scroll Mechanism + +๐ Known Issues + +API requests may fail if the free API limit is reached. + +Slow networks can cause delayed image loading. + +Some articles might not contain images or descriptions from the API. + +๐ Future Enhancements + +Add dark/light mode toggle. + +Save favorite articles using local storage. + +Add โTop Stories by Countryโ filter. + +Implement voice-based news search. + +Add a simple offline PWA version. + +๐ License + +MIT License โ Free for learning and personal use. + +๐ค Contributing + +This project is part of ProjectHive Frontend Domain. +Feel free to: + +Fork and enhance the app + +Report bugs or suggest improvements + +Use it for your portfolio or learning practice \ No newline at end of file diff --git a/Domains/Frontend/MiniProjects/NewsFlash/index.html b/Domains/Frontend/MiniProjects/NewsFlash/index.html new file mode 100644 index 00000000..f620c55c --- /dev/null +++ b/Domains/Frontend/MiniProjects/NewsFlash/index.html @@ -0,0 +1,35 @@ + + +
+ + +No news found ๐ฐ
`; + } + loader.classList.add("hidden"); + loading = false; + return; + } + + displayNews(data.articles); + } catch (err) { + console.error("Error fetching news:", err); + newsContainer.innerHTML = `Error loading news. Check API key or network.
`; + } + + loader.classList.add("hidden"); + loading = false; +} + +function displayNews(articles) { + articles.forEach(article => { + const card = document.createElement("div"); + card.classList.add("news-card"); + card.innerHTML = ` +${article.description || "No description available."}
+ Read More โ +