if variable is not set then use default value

Hi everybody. I am finishing this program but there is just one detail.
I need to define the number of files that have to be deleted in this way MAXFILES=3 ./program 1 2 3 4 if the $# is > MAXFILES then confirm otherwise just delete them. But if i don't define the MAXFILES like ./program 1 2 3 4 then there is a default number which is 10. more than 10 confirm otherwise just delete them. But the program that I have so far just works with the MAXFILES and I am not sure how to make it work with both ways. Here it is. Thank you very much in advanced.

i=10
x=$MAXFILES

if [ "$x" -ne 10 ]
    then
if [ "$#" -gt "$x" ]
    then
      echo "Remove $# files (y/n)?"
      read ans
         if [ "$ans" != n ]
             then
                rm "$@"
                echo "Files removed!"
         else
             echo "Files not removed"
         fi
     else
     rm "$@"
     echo "Files have been removed!"
fi
else
    if [ "$#" -eq 10 ]
        then
        echo "Remove $# files (y/n)?"
      read ans
         if [ "$ans" != n ]
             then
                rm "$@"
                echo "Files removed!"
         else
             echo "Files not removed"
         fi
     else
     rm "$@"
     echo "Files have been removed!"
   fi
fi
$ x=$MAXFILES
$ echo $x

$ x=${MAXFILES:-10}
$ echo $x
10
$ MAXFILES=5
$ x=${MAXFILES:-10}
$ echo $x
5