#!/bin/bash
# functions07, was example07
# silly-with-functions 20080415rm


get_response()
	{
	clear
	echo -e "\n\t\t\tWhat does `whoami` want to do?\n"
	echo -e "\t\t\tMake a selection from the following by"
	echo -e "\t\t\ttyping in the corresponding number then"
	echo -e "\t\t\thitting enter.  \c" 
	sleep 1
	echo -e "\n\n\t\t\t1  Do nothing"
	echo -e "\t\t\t2  Get the time and date"
	echo -e "\t\t\t3  Do something silly"
	echo -e "\t\t\t\t\c"
	read response
	}

response_one() # function if response is 1
	{
	echo -e "\n\n\t\t\tLooks like we're feeling lazy today :^)\n\n\n"
	sleep 5 
	}

response_two()
	{
	echo -e "\n\n\t\t\t`date`" 
	sleep 4
	clear
	}

response_three()
	{
	clear
	silly=0
	while [  $silly -lt 10 ]; do 
		echo -e "\n\n\n\t\t\c"
		sleep 1
		echo -e "`whoami` is a darn nice person, I \c"
		echo -e "don't care what anybody says!  \c"
		sleep 1 
		clear
		let silly=$silly+1 
    done
	sleep 2
	}

bad_response()
	{
	clear
	echo -e "\n\n\t\t\tYou did not respond correctly!!"
	sleep 2
	echo -e "\n\t\tYou are lucky I didn't put you in an infinit loop!"
	sleep 2
	echo -e "\n\t\tYou will now have to wait 1 minute before you get"
	echo -e "\t\tget your command prompt back  \c"
	sleep 10
	echo -e "\n\n\n\n"
	}	

# Functions go before the main part of the script
# Bash will run commands in functions when the function is 
# called by name in the script
# The main part of this function follows:

get_response

case $response in
	1) response_one
	;;  
	2) response_two
	;;
	3) response_three 
	;;
	*) bad_response
	;;
esac

#end of script