all tests pass

This commit is contained in:
Ryan Voots 2012-09-06 20:08:56 -07:00
parent 5b59a4d39b
commit 1b191e3d90

View file

@ -2,6 +2,7 @@ package OOPerlTest::Personal::Person::Employee::Manager;
use Moose;
use POSIX qw(strftime);
use Data::Dumper;
extends 'OOPerlTest::Personal::Person::Employee';
@ -27,14 +28,26 @@ sub Hire {
return $empl;
}
sub Fire {}
sub Fire {
my ($self, $empl) = @_;
# get rid of the employee from the list
my @empls = grep {$_ ne $empl} @{$self->employees};
$self->employees(\@empls);
my $person = OOPerlTest::Personal::Person->new({
name => $empl->name(),
($empl->alias() ? (alias => $empl->alias()) : ()),
dateOfBirth => $empl->dateOfBirth(),
});
return $person;
}
sub Work {
my ($self, $work) = @_;
# don't work if it's already done
return $work if ($work->status() eq "NotStarted" || $work->status() eq "Started");
return $work if ($work->status() eq "Completed" || $work->status() eq "Rejected");
# this will naively pick the first person always to work. any real system should distrubute the work
if (@{$self->employees()} >= 1) {
@ -55,7 +68,17 @@ sub Work {
}
sub Quit {}
sub Quit {
my ($self) = @_;
my $empl = OOPerlTest::Personal::Person::Employee->new({
name => $self->name(),
($self->alias() ? (alias => $self->alias()) : ()),
dateOfBirth => $self->dateOfBirth(),
hireDate => $self->hireDate(),
});
return $empl;
}
sub WorkUnitsProcessed {
my ($self) = @_;