New structure groups all ADT modules under adt/ directory, removing redundant adt- prefix from filenames. Library names now read as (pacman-project adt position) etc. All imports updated accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 lines
1011 B
Racket
33 lines
1011 B
Racket
#lang r7rs
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Score ADT ;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Tracks the player's score. Contains NO graphics code.
|
|
|
|
(define-library (pacman-project adt score)
|
|
(import (scheme base)
|
|
(pacman-project constants))
|
|
(export make-score)
|
|
|
|
(begin
|
|
|
|
;; make-score :: -> score
|
|
;; Creates a new score object, starting at 0.
|
|
(define (make-score)
|
|
(let ((points 0))
|
|
|
|
;; increase! :: -> /
|
|
;; Increases the score by points-per-coin.
|
|
(define (increase!)
|
|
(set! points (+ points points-per-coin)))
|
|
|
|
;; dispatch-score :: symbol -> any
|
|
(define (dispatch-score msg)
|
|
(cond ((eq? msg 'points) points)
|
|
((eq? msg 'increase!) increase!)
|
|
(else (error "Score ADT -- Unknown message:" msg))))
|
|
|
|
dispatch-score))))
|