# GeoSimulator.pm
#
# Copyright (c) 2002 Cunningham & Cunningham, Inc.
# Released under the terms of the GNU General Public License version 2 or later.
#
# Perl translation by Dave W. Smith <dws@postcognitive.com>

package GeoSimulator;

use lib qw(../Fit);

use base qw(Fixture);
use strict;
use GeoCoordinate;

sub new {
    my $pkg = shift;

    return $pkg->SUPER::new(zip => [],
	                    coord => new GeoCoordinate(),
	                    nodes => 0,
	                    @_);
}

sub newCity {
    my $self = shift;
}

sub ok {
    my $self = shift;

    $self->{'nodes'}++;
}

sub cancel {
    my $self = shift;
}

sub name {
    my $self = shift;
    my($name) = @_;
}

sub zip {
    my $self = shift;

    $self->{'zip'} = [ @_ ] if @_;

    return $self->{'zip'};
}

sub population {
    my $self = shift;
    my($p) = @_;
}

sub coord {
    my $self = shift;

    $self->{'coord'} = $_[0] if @_;
    return $self->{'coord'}
}

sub nodes {
    my $self = shift;

    return $self->{'nodes'};
}

sub parse {
    my $self = shift;
    my($string, $type) = @_;

    return GeoCoordinate->parse($string) if $type eq "GeoCoordinate";	#TBD this isn't gonna work!
    return $self->SUPER::parse($string, $type);
}


1;

__END__
package eg.net;

// Copyright (c) 2002 Cunningham & Cunningham, Inc.
// Released under the terms of the GNU General Public License version 2 or later.

import fit.Fixture;

public class Simulator extends Fixture {
    int zip[];
    GeoCoordinate coord;
    int nodes=0;

    public void newCity() {
    }

    public void ok() {
        nodes++;
    }

    public void cancel() {
    }

    public void name(String n) {
    }

    public void zip(int[] z) {
        zip = z;
    }

    public int[] zip() {
        return zip;
    }

    public void population (Float p) {
    }

    public void coord (GeoCoordinate c) {
        coord = c;
    }

    public GeoCoordinate coord () {
        return coord;
    }


    public int nodes() {
        return nodes;
    }

    public Object parse (String string, Class type) throws Exception {
        if (type.equals(GeoCoordinate.class)) {return GeoCoordinate.parse(string);}
        return super.parse (string, type);
    }

}
