package Residue;

@ISA = qw(chemistry);

sub new {
	my $class = shift;
	$self = { 
		name => "", 
		atoms => [], 
		totCharge => 0.0,
		prev => 0,
		next => 0
		 };
	bless $self;
}

sub name {
	my ($self, $name) = @_;
	$self->{name} = $name if defined $name;
	return $self->{name};
}

sub totCharge {
	my $self = @_;
	return $self->{totCharge};
}

sub getCharge {
	my $self = shift;
	$self->{totCharge}= 0.0;
	for my $at  (@{$self->{atoms}}) {
		$self->{totCharge} += $at->charge;
	}
	return $self->{totCharge};
}

sub addAtom {
	my ($self, $at) = @_;
	push @{$self->{atoms}}, $at;
	$self->{totCharge} += $at->charge;
	$self->{numAtoms} = scalar @{$self->{atoms}};
	return $self;
}

sub atoms {
	my $self = shift;
	return $self->{atoms};
};

sub numAtoms {
	my $self = shift;
	return scalar @{$self->{atoms}};
}

sub rmAtom {
	my ($self, $name) = @_;
	my $i=0;
	while (($self->{atoms}[$i]->name ne $name) && ($i < $self->{numAts})) {$i++};
	if ($self->{atoms}[$i]->name eq $name) {
		splice (@{$self->{atoms}},$i,1);
		$self->{numAts}--;
	}
	return $self;
}

sub prev {
	my ($self, $prev) = @_;
	$self -> {prev} = $prev if defined $prev;
	return $self->{prev};
}

sub next {
	my ($self, $next) = @_;
	$self -> {next} = $next if defined $next;
	return $self->{next};
}



"1";
	

