use Door; use MyApp::Bundle; my $front = Door->new(name => 'Front'); my $back = Door->new(name => 'Back'); sub say_doors_state { say ' ' . $front->to_str . ' | ' . $back->to_str; say ''; } say 'START in the house...'; say '...the doors are Closed and Unlocked (default)'; say_doors_state; # Front: CLOSED, UNLOCKED | Back: CLOSED, UNLOCKED say 'Lock the Front door'; $front->lock; say_doors_state; # Front: CLOSED, LOCKED | Back: CLOSED, UNLOCKED say 'Try to open the Front door (impossible)'; $front->open; say_doors_state; # you cannot open a locked door # Front: CLOSED, LOCKED | Back: CLOSED, UNLOCKED say 'Open the Back door'; $back->open; say_doors_state; # Front: CLOSED, LOCKED | Back: OPENED, UNLOCKED say 'Try to lock the Back door (impossible)'; $back->lock; say_doors_state; # you cannot lock an open door at test.pl line 26. # Front: CLOSED, LOCKED | Back: OPENED, UNLOCKED say 'Close the Back door'; $back->close; say_doors_state; # Front: CLOSED, LOCKED | Back: CLOSED, UNLOCKED say 'Lock the Back door'; $back->lock; say_doors_state; # Front: CLOSED, LOCKED | Back: CLOSED, LOCKED say "I'm safe!";