module rectangle_module use shape_module type, extends (shape_type) :: rectangle_type integer, private :: width_ integer, private :: height_ contains procedure, pass (this) :: getwidth procedure, pass (this) :: setwidth procedure, pass (this) :: getheight procedure, pass (this) :: setheight procedure, pass (this) :: draw => draw_rectangle end type rectangle_type interface rectangle_type module procedure rectangle_type_constructor end interface rectangle_type contains type (rectangle_type) function rectangle_type_constructor(x, y, width, height) implicit none integer, intent (in) :: x integer, intent (in) :: y integer, intent (in) :: width integer, intent (in) :: height call rectangle_type_constructor%setx(x) call rectangle_type_constructor%sety(y) rectangle_type_constructor%width_ = width rectangle_type_constructor%height_ = height end function rectangle_type_constructor integer function getwidth(this) implicit none class (rectangle_type), intent (in) :: this getwidth = this%width_ end function getwidth subroutine setwidth(this, width) implicit none class (rectangle_type), intent (inout) :: this integer, intent (in) :: width this%width_ = width end subroutine setwidth integer function getheight(this) implicit none class (rectangle_type), intent (in) :: this getheight = this%height_ end function getheight subroutine setheight(this, height) implicit none class (rectangle_type), intent (inout) :: this integer, intent (in) :: height this%height_ = height end subroutine setheight subroutine draw_rectangle(this) implicit none class (rectangle_type), intent (in) :: this print *, ' x = ', this%getx() print *, ' y = ', this%gety() print *, ' width = ', this%width_ print *, ' height = ', this%height_ end subroutine draw_rectangle end module rectangle_module