This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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."); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ==="); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//singleinheritance | |
//superclass | |
class Animal { | |
void eat() { | |
System.out.println("This animal eats food."); | |
} | |
void sleep() { | |
System.out.println("This animal sleep at night."); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque | |
from datetime import datetime | |
from typing import List, Optional | |
import uuid | |
class Event: | |
""" | |
Represents an event in the processing system. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Print("hello") |