Professional Documents
Culture Documents
Tabsum Khadkaa Code
Tabsum Khadkaa Code
#!/bin/bash
Players(){
echo -e " Type Any 3 player codes among five:\c"
read player1 player2 player3
playerchoose=($player1 $player2 $player3)
if [[ ${#playerchoose[@]} -lt 3 ]]
then
echo "Enter atleast three player codes."
Players
elif [[ ${#playerchoose[@]} -gt 3 ]]
then
echo "Enter only three player codes."
Players
elif [[ ${#playerchoose[@]} = 3 ]]
then
if [[ $playerchoose != PK && $playerchoose != VK &&
$playerchoose != DW && $playerchoose != BS && $playerchoose != RT ]]
then
echo "Some player code is not from the table"
Players
elif [[ $player1 == $player2 || $player2 == $player3 ||
$player3 == $player1 ]]
then
echo "Same player repeated more than one time.
Please enter unique player code."
Players
else
PS3="Choose only one number as option: "
select playerNumber in $player1 $player2 $player3 #here select
statement is used to select the answer from array
do
case $playerNumber in #here switch case is used to show the
files according to users input
PK)
cat PK
break
;;
VK)
cat VK
break
;;
RT)
cat RT
break
;;
BS)
if [ ! -f "BS" ]
then
echo "Sorry,No description avaiable
for BS" #these files are absent so it shows message
echo ""
echo ""
echo "REDIRECTING TO COUNTRY
SELCTION..."
countrycode
fi
break
;;
DW)
if [ ! -f "DW" ]
then
*)
echo "No player name found" #if user enters
wrong answer like diffrnt character or number it will show messages
Players
break
;;
esac
done
repeat
fi
fi
}
repeat()
{
echo -e "DO you want to return back to country selection(Y/N):\c"
read response
if [[ ${#response[@]} = 0 ]]
then
repeat
fi
}
chooseCountry()
{
echo -e "Guess the best Cricket team from the above given table(Insert
code):\c"
read countrycode
if [[ $countrycode == "NEP" ]]
then
echo ""
echo "Congrats!!! You have choosen the right country code.
Nepal has the best Cricket team."
echo ""
echo "DESCRIPTION OF NEPAL"
echo "===================="
echo ""
echo "The Rhinos and Gorkhalis,represents the country of
Nepal in the international cricket amd is governed by the Cricker
Assossiation of Nepal ( CAN ). Nepal were awarded Twenty international
status by the ICC in June 2014 until the 2015 ICC World Twenty Qualifier. "
echo ""
echo""
echo -e "The list of the five players are: "
echo ""
echo "----------------------------"
}
if [[ "$#" = 2 ]]
then
if [[ $1 != "Tabsum" ]]
then
echo "Invalid username $1. Please enter correct username."
exit
elif [[ $2 != "18030084" ]]
then
echo "Invalid ID number $2. Please enter correct ID
number."
exit
fi
secretKey $1 $2
else
echo "Enter two parameters-| Username and ID Number | "
exit
fi