Skip to content

Commit

Permalink
Mods in Adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
farhanjk committed Dec 27, 2013
1 parent addc798 commit 48971f1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Binary file modified structural/adapter/adapter_main
Binary file not shown.
24 changes: 17 additions & 7 deletions structural/adapter/adapter_module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,26 @@ subroutine showSmilesInterface(this)
end type concreteConsultant

!Consultant adapter paves path between consultant and employee
type, extends(employee) :: consultantAdapter
class(consultant), allocatable :: c
contains
procedure :: showHappiness => showHappinessConsultantAdapterImpl
end type consultantAdapter
type, extends(employee), abstract :: consultantAdapterIntermediary
end type consultantAdapterIntermediary

!Constructor for initializing the adapter
interface consultantAdapter
module procedure init_consultantAdapter
end interface

!Consultant adapter paves path between consultant and employee
type, extends(consultantAdapterIntermediary) :: consultantAdapter
class(consultant), allocatable :: c
contains
procedure :: showHappiness => showHappinessConsultantAdapterImpl
procedure :: showSmiles => showSmilesConsultantAdapterImpl
end type consultantAdapter
contains

type(consultantAdapter) function init_consultantAdapter(c)
class(consultant), intent(in) :: c
allocate(init_consultantAdapter%c, source = c)
init_consultantAdapter%happiness = c%smiles
end function

subroutine showHappinessImpl(this)
Expand All @@ -78,6 +82,12 @@ subroutine showSmilesImpl(this)

subroutine showHappinessConsultantAdapterImpl(this)
class(consultantAdapter), intent(in) :: this
print *, this%happiness
print *, this%c%smiles
end subroutine


subroutine showSmilesConsultantAdapterImpl(this)
class(consultantAdapter), intent(in) :: this
print *, this%c%smiles
end subroutine
end module adapter_module

0 comments on commit 48971f1

Please sign in to comment.