+++ /dev/null
-package Employee;
-
-use Moose;
-
-extends 'Person';
-
-has '+title' => (
- default => 'Worker',
-);
-
-has salary_level => (
- is => 'rw',
- default => 1,
-);
-
-has salary => (
- is => 'ro',
- lazy => 1,
- builder => '_build_salary',
- init_arg => undef,
-);
-
-has ssn => ( is => 'ro' );
-
-sub _build_salary {
- my $self = shift;
-
- return $self->salary_level * 10000;
-}
-
-no Moose;
-
-__PACKAGE__->meta->make_immutable;
-
-1;
+++ /dev/null
-package HasAccount;
-
-use Moose::Role;
-
-has balance => (
- is => 'rw',
- default => 100,
-);
-
-sub deposit {
- my $self = shift;
- my $amount = shift;
-
- $self->balance( $self->balance + $amount );
-}
-
-sub withdraw {
- my $self = shift;
- my $amount = shift;
-
- die "Balance cannot be negative"
- if $self->balance < $amount;
-
- $self->balance( $self->balance - $amount );
-}
-
-no Moose::Role;
-
-1;
+++ /dev/null
-package Person;
-
-use Moose;
-
-with 'Printable', 'HasAccount', 'OutputsXML';
-
-has title => (
- is => 'rw',
- predicate => 'has_title',
- clearer => 'clear_title',
-);
-
-has first_name => ( is => 'rw' );
-
-has last_name => ( is => 'rw' );
-
-sub full_name {
- my $self = shift;
-
- my $title = join q{ }, $self->first_name, $self->last_name;
- $title .= q[ (] . $self->title . q[)]
- if $self->has_title;
-
- return $title;
-}
-
-sub as_string { $_[0]->full_name }
-
-no Moose;
-
-__PACKAGE__->meta->make_immutable;
-
-1;