!///////////////////////////////////////////////////////////////////
!//
!// class_test.f90
!//
!// A program to test the functionality of a class declaration
!// with subclass
!//
!///////////////////////////////////////////////////////////////////

PROGRAM class_test
  !// Use the class_example module
  USE class_example
  IMPLICIT NONE
  !// Declare a variable of the class circle
  TYPE(circle)             :: C
  !// Declare a variable of the class sphere
  TYPE(sphere)             :: S
  !// Declare a variable of the class rectangle
  TYPE(rectangle)          :: Re
  !// Declare a variable of the class box
  TYPE(box)                :: B
  !// A variable to hold the radius of the circle
  !// and sphere
  REAL(KIND=8)             :: r
  !// Set the radius
  r = 1.5
  !// Create an instance of C using intrinsic constructor
  !// with the radius as argument
  C = circle(r)
  !// Call the subroutine associated with this
  !// instance
  CALL C%circ()
  !// Print the result
  PRINT *, 'The circumference of the instance of C ', C%circumference
  !// Create an instance of S using intrinsic constructor
  !// with the radius as argument
  S = sphere(r)
  !// Call the subroutine associated with this
  !// instance
  CALL S%spvol()
  !// Print the result
  PRINT *, 'The volume of the instance of S ',S%volume
  CALL S%circ()
  !// Print the result
  PRINT *, 'The circumference of the instance of S ', CS%circumference
  !// Create an instance of S using intrinsic constructor
  !// with the x and y length as arguments
  Re = rectangle(2,3)
  !// Call the subroutine associated with this
  !// instance
  CALL Re%rarea()
  !// Print the result
  PRINT *, 'The circumference of the instance of Re  ', Re%area
  !// Give the length of the sides of the bos instance
  B%x_direction = 2
  B%y_direction = 3
  B%height = 4
  !// Call the subroutine associated with this
  !// instance
  CALL B%bvol()
  !// Print the result
  PRINT *, 'The volume of the instance of B  ', B%volume
  !// Call the subroutine associated with this
  !// instance
  CALL B%rarea()
  !// Print the result
  PRINT *, 'The area of the instance of B  ', B%area
END PROGRAM class_test
