Skip to content

Instantly share code, notes, and snippets.

View thinkphp's full-sized avatar

Adrian Statescu thinkphp

View GitHub Profile
cartItem.innerHTML = `
<div class="item-info">
<h3 class="item-title">${item.name}</h3>
<div class="item-price">$${item.price.toFixed(2)} each</div>
</div>
<div class="item-controls">
<button class="decrease-quantity" data-id="${item.id}">-</button>
<span class="item-quantity">${item.quantity}</span>
<button class="increase-quantity" data-id="${item.id}">+</button>
<button class="remove-item" data-id="${item.id}" style="margin-left: 10px; background-color: #f44336;">×</button>
@thinkphp
thinkphp / afisare_produse.js
Last active April 18, 2025 13:10
afisare produse
document.querySelectorAll('.add-to-cart-button').forEach(button => {
button.addEventListener('click', addToCart);
});
function afisare_produse() {
for (let i = 0; i < coffeeProducts.length; i++) {
const product = coffeeProducts[i];
const create_product_card = document.createElement("div");
create_product_card.classList.add("product-card");
productCard.innerHTML = `
<div class="product-image">Coffee Image: ${product.name}</div>
<div class="product-info">
<h3 class="product-title">${product.name}</h3>
<div class="product-price">$${product.price.toFixed(2)}</div>
<div class="product-description">${product.description}</div>
<button class="add-to-cart-button" data-id="${product.id}">Add to Cart</button>
</div>
`;
@thinkphp
thinkphp / WavFile.java
Last active April 17, 2025 18:41
WaveFile VA07 Task
public class WavFile extends SampledFile {
public WaveFile() {
super();
}
public WavFile(String path) {
}
@thinkphp
thinkphp / PlayList.java
Created April 17, 2025 18:06
PlayList Task va08
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.LinkedList;
import java.util.List;
public class PlayList {
@thinkphp
thinkphp / AudioFileFactory.java
Created April 17, 2025 17:23
AudioFileFactory.java
public class AudioFileFactory {
/**
creeaza o instanta AudioFile corespunzatoare in functie de extensia fisierului
@param path Calea catre fisierul audio
@return o instanta AudioFile corespunzatoare
@throws RuntimeException daca extensia fisierului nu este suportata
*/
@thinkphp
thinkphp / transport.java
Created April 17, 2025 17:08
Transportation Factory Design Pattern
//abstract product
abstract class Transport {
protected String cargo;
protected String destination;
public void setCargo(String cargo) {
this.cargo = cargo;
}
@thinkphp
thinkphp / factory-design pattern.java
Created April 17, 2025 16:41
Factory Design Pattern
/*
Modelul de Design Factory este un model creational care ofera o interfata pentru crearea obiectelor intr-o superclasa, dar permite
subclaselor sa modifice tipul obiectelor care vor fi create. Acest model este deosebit de util cand avem nevoie de un mod de a crea
diferite obiecte, dar dorim sa separam codul clientului de clasele concrete
*/
abstract class Document {
protected String name;
protected String content;
themeToggle.addEventListener('click', () => {
const html = document.documentElement;
const currentTheme = html.getAttribute('data-theme');
const newTheme = currentTheme === 'light' ? 'dark' : 'light';
html.setAttribute('data-theme', newTheme);
// Update the button icon
if (newTheme === 'dark') {
moonIcon.style.display = 'none';
sunIcon.style.display = 'block';
} else {
@thinkphp
thinkphp / order-coffee-html.html
Created April 12, 2025 12:50
Order Coffee html
<body>
<div class="container">
<header class="header">
<h1>Coffee Shop</h1>
<p>Select your favorite coffee and add it to cart</p>
</header>
<main class="products" id="products-container">
<!-- Products will be added here by JavaScript -->
</main>