coord.st 548 Bytes
Newer Older
1
2
3
4
5
6
7
8
Object subclass: Coord [
    | x y |
    <comment: 'I represent a location in a world, containing a cell either alive or dead'>

    Coord class >> newWithX:x y:y [
        | c |
        c := super new.
        c initWithX:x y:y.
9
        ^c ]
10
11
12

    initWithX:xValue y:yValue [
        x := xValue.
13
        y := yValue ]
14
15
16
17

    printOn: stream [
        x displayOn: stream.
        ':' displayOn: stream.
18
        y displayOn: stream ]
19
20
21
22
23
24
25

    x [ ^x ]

    y [ ^y ]

    = arg [ ^ x = arg x and: [ y = arg y ] ]

26
    hash [ ^ self displayString hash ] ]