Files
Pacman-Project/pacman-project/adt-score.rkt
joren cd70055bc7 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>
2026-03-23 11:06:32 +01:00

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))))