Refactor(English): Rename all files and identifiers from Dutch to English
Renamed files: constanten→constants, adt-positie→adt-position, adt-doolhof→adt-maze, adt-sleutel→adt-key, adt-tijdslimiet→adt-timer, adt-teken→adt-draw, adt-spel→adt-game. All message names, variables, comments, and tests converted to English. Also fixed counter location bug (time-label x/y were swapped). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
50
pacman-project/adt-position.rkt
Normal file
50
pacman-project/adt-position.rkt
Normal file
@@ -0,0 +1,50 @@
|
||||
#lang r7rs
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Position ADT ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; A position represents a location on the logical maze grid.
|
||||
;; Coordinates are in grid units (row, col), NOT pixels.
|
||||
|
||||
(define-library (pacman-project adt-position)
|
||||
(import (scheme base))
|
||||
(export make-position)
|
||||
|
||||
(begin
|
||||
|
||||
;; make-position :: number, number -> position
|
||||
;; Creates a new position object with row and column on the grid.
|
||||
(define (make-position row col)
|
||||
|
||||
;; row! :: number -> /
|
||||
(define (row! new-row)
|
||||
(set! row new-row))
|
||||
|
||||
;; col! :: number -> /
|
||||
(define (col! new-col)
|
||||
(set! col new-col))
|
||||
|
||||
;; equal? :: position -> boolean
|
||||
;; Checks whether two positions have the same coordinates.
|
||||
(define (equal? other)
|
||||
(and (= row (other 'row))
|
||||
(= col (other 'col))))
|
||||
|
||||
;; move :: number, number -> position
|
||||
;; Returns a new position shifted by delta-row and delta-col.
|
||||
(define (move delta-row delta-col)
|
||||
(make-position (+ row delta-row)
|
||||
(+ col delta-col)))
|
||||
|
||||
;; dispatch-position :: symbol -> any
|
||||
(define (dispatch-position msg)
|
||||
(cond ((eq? msg 'row) row)
|
||||
((eq? msg 'col) col)
|
||||
((eq? msg 'row!) row!)
|
||||
((eq? msg 'col!) col!)
|
||||
((eq? msg 'equal?) equal?)
|
||||
((eq? msg 'move) move)
|
||||
(else (error "Position ADT -- Unknown message:" msg))))
|
||||
|
||||
dispatch-position)))
|
||||
Reference in New Issue
Block a user