Refactor(Structure): Move ADTs into adt/ folder, rename spel.rkt to main.rkt
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>
This commit is contained in:
32
pacman-project/adt/score.rkt
Normal file
32
pacman-project/adt/score.rkt
Normal file
@@ -0,0 +1,32 @@
|
||||
#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))))
|
||||
Reference in New Issue
Block a user