Skip to content

Instantly share code, notes, and snippets.

View awesansari-git's full-sized avatar

awesansari-git

  • Joined Aug 21, 2025
View GitHub Profile
class CallCenterQueue:
def __init__(self, max_size=100):
self.queue = [None] * max_size # fixed size queue
self.front = -1
self.rear = -1
self.max_size = max_size
# Add a call to the queue
def addCall(self, customerID, callTime):
if (self.rear + 1) % self.max_size == self.front:
print("Queue is Full! Cannot add more calls.")
// Superclass (Parent class)
class Animal {
// Method in superclass
void eat() {
System.out.println("This animal eats food.");
}
void sleep() {
System.out.println("This animal sleeps at night.");
}
import java.util.Scanner;
public class RobustCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
boolean continueCalc = true;
System.out.println("=== Welcome to the Robus66t Calculator ===");
//singleinheritance
//superclass
class Animal {
void eat() {
System.out.println("This animal eats food.");
}
void sleep() {
System.out.println("This animal sleep at night.");
}
}
import java.util.Scanner;
public class HotelRoomBooking {
private static final int FLOORS = 3; // Number of floors
private static final int ROOMS_PER_FLOOR = 5; // Number of rooms per floor
private static boolean[][] rooms = new boolean[FLOORS][ROOMS_PER_FLOOR]; // false = available, true = booked
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int choice;
class Student:
"""Student class to store student data"""
def __init__(self, roll_no, name, marks):
self.roll_no = roll_no
self.name = name
self.marks = marks
def __str__(self):
return f"Roll: {self.roll_no}, Name: {self.name}, Marks: {self.marks}"
class Call:
"""Simple class to represent a call"""
def __init__(self, customer_id, call_time):
self.customer_id = customer_id
self.call_time = call_time
def __str__(self):
return f"Customer {self.customer_id} (Call time: {self.call_time} min)"
from collections import deque
from datetime import datetime
from typing import List, Optional
import uuid
class Event:
"""
Represents an event in the processing system.
"""
class TextEditor:
def __init__(self):
self.document = "" # Current document state
self.undo_stack = [] # Stack to store undo history
self.redo_stack = [] # Stack to store redo history
def make_change(self, new_text):
# Save current state before making a new change
self.undo_stack.append(self.document)
# Clear redo stack on new change