Skip to content

cmm25/hospital-priority-queue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Hospital Priority Queue Simulation

This Python script simulates a hospital priority queue using Pygame and Tkinter. The program allows users to add patients with different priorities, remove patients with the least priority, and perform other operations.

Pygame Setup

import pygame
import heapq
import tkinter as tk
from tkinter import messagebox
  1. Initialization: Pygame and Tkinter are initialized.
pygame.init()

Constants

WIDTH, HEIGHT = 1000, 650
BACKGROUND = (228, 213, 199)
# ... (Other constants)
  1. Constants: Screen dimensions, colors, and button properties are defined.

Priority Queue

priority_queue = []
  1. Priority Queue Initialization: The priority queue is initialized as an empty list.

Pygame Setup

screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Hospital Priority Queue")
font = pygame.font.Font(None, FONT_SIZE)
  1. Pygame Setup: Pygame window, font, and other essential elements are set up.

Functions

def draw_text(text, rect, color=BLACK):
    # ... (Implementation)

def draw_priority_queue():
    # ... (Implementation)

def is_button_clicked(pos, button_rect):
    # ... (Implementation)

def update_patient_numbers():
    # ... (Implementation)

def is_input_area_hovered(pos, input_rect):
    # ... (Implementation)

def show_error(message):
    # ... (Implementation)

def show_max_capacity_error():
    # ... (Implementation)

def add_patient(patient_name, patient_age, patient_priority):
    # ... (Implementation)

# ... (Other functions)
  1. Helper Functions: Functions for rendering text, drawing the priority queue, checking button clicks, and error handling are defined.

Tkinter Setup

root = tk.Tk()
root.withdraw()
  1. Tkinter Setup: Tkinter is set up for error alert messages.

Main Loop

running = True
while running:
    for event in pygame.event.get():
        # ... (Event handling)

    screen.fill(BACKGROUND)

    # ... (Drawing elements)

    pygame.display.flip()

# Quit Tkinter
root.destroy()
pygame.quit()
  1. Main Loop: The main loop handles Pygame events, button clicks, and updates the display.

Summary

This script simulates a hospital priority queue where patients are added with a given priority, and the "Remove Patient" button removes the patient with the least priority. The code also includes error handling and the ability to display the length of the priority queue.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages