diff --git a/Blogs.md b/Blogs.md new file mode 100644 index 000000000..092fd1d68 --- /dev/null +++ b/Blogs.md @@ -0,0 +1,10 @@ +--- +layout: post +title: Blogs +description:Blogs +categories: [Javascript] +menu: nav/javascript_project.html +permalink: /javascript/project/Blogs +toc: true +comments: false +--- diff --git a/Makefile b/Makefile index 7d9cdaf86..0e48753f0 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Configuration, override port with usage: make PORT=4200 PORT ?= 4100 -REPO_NAME ?= student_2025 +REPO_NAME ?= Amal_2025 LOG_FILE = /tmp/jekyll$(PORT).log SHELL = /bin/bash -c @@ -92,4 +92,4 @@ stop: @# kills previously running logging processes @@ps aux | awk -v log_file=$(LOG_FILE) '$$0 ~ "tail -f " log_file { print $$2 }' | xargs kill >/dev/null 2>&1 || true @# removes log - @rm -f $(LOG_FILE) + @rm -f $(LOG_FILE) \ No newline at end of file diff --git a/README4YML.md b/README4YML.md deleted file mode 100644 index defd8f31a..000000000 --- a/README4YML.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -layout: post -title: Readme -toc: true ---- - -{% include_relative README.md %} diff --git a/Snake.md b/Snake.md new file mode 100644 index 000000000..aa3806558 --- /dev/null +++ b/Snake.md @@ -0,0 +1,389 @@ +--- +layout: post +title: Snake Game +description: A Javascript Snake game that contains score and preferences. +categories: [Javascript] +menu: nav/javascript_project.html +permalink: /javascript/project/snake +toc: true +comments: false +--- + + + + +
Snake score: 0
+![]() |
+CSP | + +
![]() |
+ Play | +Binary | +Calculator | +Game-of-Life | +Music | +Snake | +Blogs | + +
\n", + "
\n", + " \n", + "Name | \n", + "GitHub ID | \n", + "Class Of | \n", + "Role | \n", + "
---|---|---|---|
${row.name} | \n", + "${row.ghID} | \n", + "${row.classOf} | \n", + "${row.role} | \n", + "
This example uses data types, operators, and functions to scale a block based on a user-defined width.
\n", + "\n", + "\n", + "This example uses data types, operators, and functions to scale a block based on a user-defined width.
\n", + "\n", + "\n", + "This example uses data types, operators, and functions to scale a block based on a user-defined width.
\n", + "\n", + "\n", + "This example uses data types, operators, and functions to scale a block based on a user-defined width.
\n", + "\n", + "\n", + "An if statement is a decision-making tool in programming that allows code to run only if a specific condition is true. It makes code responsive to changing inputs or situations.
\n", + "\n", + "if (condition) {\n",
+ "// code to execute if condition is true\n",
+ "}
\n",
+ "// Prompt the user for their favorite fruit\n",
+ "let fruit = prompt(\"What's your favorite fruit?\");\n",
+ "\n",
+ "// If the fruit is \"mango,\" respond with a specific message\n",
+ "if (fruit === \"mango\") {\n",
+ "console.log(\"That sounds super yummy!\");\n",
+ "}
\n",
+ "An if-else statement expands on the if statement by adding an alternative code block that executes if the initial condition is false. This allows for more complex decision trees in code.
\n", + "\n", + "if (condition) {\n",
+ "// code if condition is true\n",
+ "} else {\n",
+ "// code if condition is false\n",
+ "}
\n",
+ "// Ask the user for their favorite fruit\n",
+ "let fruit = prompt(\"What's your favorite fruit?\");\n",
+ "\n",
+ "// Ensure case-insensitive comparison\n",
+ "if (fruit.toLowerCase() === \"mango\") {\n",
+ "console.log(\"That sounds super yummy!\");\n",
+ "} else if (fruit.toLowerCase() === \"banana\") {\n",
+ "console.log(\"Sounds great!\");\n",
+ "} else {\n",
+ "console.log(`Oh, ${fruit} is alright, but mangos are better!`);\n",
+ "}
\n",
+ "Booleans allow for true/false checks. In this example, we determine if a user’s favorite fruit is available in stock and display a message accordingly.
\n", + "\n", + "// Check if a fruit is available\n",
+ "let isAvailable = true;\n",
+ "\n",
+ "if (isAvailable) {\n",
+ "console.log(\"Your favorite fruit is available!\");\n",
+ "} else {\n",
+ "console.log(\"Sorry, your favorite fruit is out of stock.\");\n",
+ "}
\n",
+ "Random values create dynamic interactions in a program. In this example, we assign random popularity scores to two fruits and determine which one is more popular.
\n", + "\n", + "// Generate random popularity scores for two fruits\n",
+ "let applePopularity = Math.floor(Math.random() * 100) + 1;\n",
+ "let orangePopularity = Math.floor(Math.random() * 100) + 1;\n",
+ "\n",
+ "console.log(\"Apple popularity score:\", applePopularity);\n",
+ "console.log(\"Orange popularity score:\", orangePopularity);\n",
+ "\n",
+ "if (applePopularity > orangePopularity) {\n",
+ "console.log(\"Apples are more popular than oranges!\");\n",
+ "} else if (applePopularity < orangePopularity) {\n",
+ "console.log(\"Oranges are more popular than apples!\");\n",
+ "} else {\n",
+ "console.log(\"Both fruits are equally popular!\");\n",
+ "}
\n",
+ "Statement Type | \n", + "Description | \n", + "Use Case | \n", + "
---|---|---|
If Statement | \n", + "Executes a block of code if a specified condition is true. | \n", + "Used for simple condition checks, such as verifying if a fruit is \"mango\". | \n", + "
If-Else Statement | \n", + "Executes one block if the condition is true, and another if it is false. | \n", + "Useful for two-way decision-making, like checking if a fruit is available. | \n", + "
Else-If Statement | \n", + "Checks additional conditions if the first condition is false. | \n", + "Used when comparing multiple values, like determining the more popular fruit. | \n", + "
This lesson covers various ways to use conditional statements in JavaScript. Each structure serves a unique purpose in decision-making, from simple checks with if statements to multiple conditions with switch statements.
\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "venv", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/_notebooks/Sprint 2/Data_Abstractions/2024-11-06-data_abstraction-homework.ipynb b/_notebooks/Sprint 2/Data_Abstractions/2024-11-06-data_abstraction-homework.ipynb new file mode 100644 index 000000000..5905025cf --- /dev/null +++ b/_notebooks/Sprint 2/Data_Abstractions/2024-11-06-data_abstraction-homework.ipynb @@ -0,0 +1,192 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "vscode": { + "languageId": "yaml" + } + }, + "outputs": [], + "source": [ + "---\n", + "comments: True\n", + "layout: post\n", + "title: Data Abstraction Homework\n", + "description: An intro to data abstraction\n", + "permalink: /csse/javascript/fundamentals/data-abstraction-homework\n", + "categories: [CSSE JavaScript Fundamentals]\n", + "author: Akhil Kulkarni, Santhosh Karthik\n", + "---" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# JavaScript BankAccount Class - Required Homework\n", + "\n", + "Create a `BankAccount` class that returns an object. Inside this function, follow these steps:\n", + "\n", + "### 1. **Initialize Balance**:\n", + "- Create a `balance` variable and initialize it to `100`, or any balance you want (representing $100).\n", + "\n", + "### 2. **Methods**:\n", + "- `deposit(amount)`: Adds a specified amount to the balance.\n", + "- `withdraw(amount)`: Deducts a specified amount from the balance, but only if there is enough balance.\n", + "- `getBalance()`: Returns the current balance.\n", + "- `transfer(amount, targetAccount)`: Transfers a specified amount from this account to another account.\n", + "\n", + "### 3. **Encapsulation**:\n", + "- Only allow access to the `balance` variable through the `deposit`, `withdraw`, `getBalance`, and `transfer` methods.\n", + "- Make sure to avoid direct access to `balance` from outside the `BankAccount` function.\n", + "\n", + "### 4. **Validation**:\n", + "- A deposit can only add positive amounts.\n", + "- A withdrawal can only occur if the account has enough balance.\n", + "- Transfers should be allowed only if both accounts have sufficient balance to complete the transaction.\n", + "\n", + "### 5. **Testing**:\n", + "- Create a new `BankAccount` instance with a starting balance.\n", + "- Call each method (`deposit`, `withdraw`, `getBalance`, `transfer`) to verify functionality.\n", + "\n", + "### 6. **Inheritance**:\n", + "- Create a subclass of `BankAccount`, called `PremiumBankAccount`, which offers additional benefits like no transaction fees or higher transfer limits, or whatever you want.\n", + "\n", + "---\n", + "\n", + "### Example Scenario:\n", + "\n", + "1. **Create two BankAccount instances**:\n", + " - Account 1 has an initial balance of $500.\n", + " - Account 2 has an initial balance of $1000.\n", + "\n", + "2. **Test the following:**\n", + " - Deposit $200 into Account 1.\n", + " - Withdraw $50 from Account 1.\n", + " - Transfer $100 from Account 2 to Account 1.\n", + " - Print the balances of both accounts.\n", + "\n", + "Make sure to implement the `transfer` method so that it checks if both accounts have enough balance before transferring money.\n", + "\n", + "---\n" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "vscode": { + "languageId": "javascript" + } + }, + "outputs": [ + { + "data": { + "application/javascript": " class BankAccount {\n\n }\n", + "text/plain": [ + "Please put your first number here
\n", + " \n", + "Please put your second number
\n", + " \n", + "Please put your first number here
\n", + " \n", + "Please put your second number
\n", + " \n", + "Please put your first number here
\n", + " \n", + "Please put your second number
\n", + " \n", + "Please put your first number here
\n", + " \n", + "Please put your second number
\n", + " \n", + "These are the specs of the iPhone 16:
\n", + " \n" + ], + "text/plain": [ + "These are the specs of the iPhone 16:
\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## How to Use `super` in Data Abstraction\n", + "\n", + "The `super` function is used to call methods or access variables from a **parent class** in a **child class**. Here’s how it works:\n", + "\n", + "- **Access Parent Variables**: You can use `super` to bring in variables or properties that are already defined in the parent class, so you don’t have to rewrite them.\n", + "- **Modify Parent Methods**: If the parent class has a method, you can use `super` to call that method and then build on it in the child class. For example, if the parent class has a `getPrice` method, you can use `super.getPrice()` in the child class to get the original price, then modify it—like multiplying it by a new factor.\n", + "\n", + "Using `super` is helpful when you know the parent method’s output but need to adjust it slightly without re-creating the whole function. This saves time and keeps the code simpler, especially for complex functions. \n", + "\n", + "---\n", + "\n", + "**Simple Summary**: \n", + "`super` lets a child class use parts of a parent class without redoing the work. It’s like copying the basics from a template and adding only the extra details you need." + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "metadata": { + "vscode": { + "languageId": "javascript" + } + }, + "outputs": [ + { + "data": { + "application/javascript": " class Product{\n constructor(price,size,taxRate) {\n this.price = price;\n this.size = size;\n this.taxRate = taxRate;\n } \n getPrice() {\n return this.price + this.taxRate * this.price;\n }\n product(){\n const className = this.constructor.name.toLowerCase();\n return \"You are ordering a \" + className + \" with a price of \" + this.getPrice() + \" dollars, a size of \" + this.size;\n }\n }\n class Bagel extends Product{\n constructor(price, size, taxRate, flavor) {\n super(price, size, taxRate);\n this.flavor = flavor;\n }\n getPrice(){\n return super.getPrice() * this.size;\n }\n product(){\n return super.product() + \" and a flavor of \" + this.flavor;\n }\n }\nvar sesameBagel = new Bagel(1.5, 2, 0.07, \"sesame\");\nconsole.log(sesameBagel.product());\n", + "text/plain": [ + "A boolean is a data type that represents one of two possible values: true
or false
. Booleans are useful for decision-making in code, as they let us determine if specific conditions are met. For example, if we want to check if someone meets the age requirement for a concert or has a ticket, we might represent these conditions as booleans.
A nested boolean is simply a boolean condition used inside another condition. When using nested conditionals (conditions inside other conditions), we can build complex decision-making logic. For example, we might check first if the person is old enough, and if they are, then check if they have a ticket. This kind of logic allows us to handle multiple conditions in a structured way.
\n", + "\n", + "Here’s an example:
\n", + "\n", + "```javascript\n", + "let isOldEnough = true; // Boolean indicating if the person meets the age requirement\n", + "let hasTicket = false; // Boolean indicating if the person has a ticket\n", + "\n", + "if (isOldEnough) { // Check if the person meets the age requirement\n", + " if (hasTicket) { // Nested condition to check if they have a ticket\n", + " console.log(\"You can attend the concert.\");\n", + " } else {\n", + " console.log(\"You need a ticket to attend the concert.\");\n", + " }\n", + "} else {\n", + " console.log(\"You do not meet the age requirement for this concert.\");\n", + "}\n", + "```\n", + "\n", + "---\n", + "\n", + "1. The code below checks if you can cook a meal at home. \n", + "2. It uses the presence of hunger, and ingredients, to determine if cooking a meal is possible at home.\n", + "3. It uses booleans in the code\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "vscode": { + "languageId": "html" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "\n", + "\n", + "\n" + ], + "text/plain": [ + "Click the button to play and pause the audio.
+ + + + + +
+Understanding and utilizing the right development tools is crucial for a successful coding journey. This section highlights the core components and additional tools that will enhance your learning experience and collaboration.
+
+Laptop Requirement: Ensure you have a laptop with development tools installed. MacOS and Windows are preferred. Chromebooks are supported by using a KASM cloud workspace.
+Version Control: GitHub will store your coding projects and serve as a collaboration hub with others.
+Code Editor: This course will use Visual Studio Code for its extensive support for programming languages and helpful coding features.
+Interactive Coding: In this course, coding will be interactive and instantaneous. Visual Studio Code, with support for Jupyter Notebooks and GitHub Pages, is ideal for coding, data analysis, capturing notes, and creating documentation.
+Web Hosting: Throughout this course, students and teachers will publish their projects and notes using GitHub pages. Students will showcase their projects and chronicle their development journey.
+
+
+
+ Scale Factor - It defines the player size and the height and width and also defies the canvas height
+
+
+ Step Factor-Speed control, player takes 1/nth steps (fast but not too fast)
+
+
+ const ANIMATION_RATE- Frames per second (FPS) for sprite animations, 'cause smooth is cool
+
+ Step 1: Get the game environment dimensions
+
+ Step 2: Set player properties (either from sprite data or default values)
+
+
+ Step 3: Load up the sprite sheet (or don’t, and be a red square superstar)
+
+
+
+
This example uses data types, operators, and functions to scale a block based on a user-defined width.
\n", + "\n", + "\n", + "This example uses data types, operators, and functions to scale a block based on a user-defined width.
\n", + "\n", + "\n", + "This example uses data types, operators, and functions to scale a block based on a user-defined width.
\n", + "\n", + "\n", + "This example uses data types, operators, and functions to scale a block based on a user-defined width.
\n", + "\n", + "\n", + "Score: 0
+