-
Notifications
You must be signed in to change notification settings - Fork 0
/
cw2part2
131 lines (128 loc) · 5.01 KB
/
cw2part2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
numofentry=0
MaxNoofEntry=4
SecretKeyEntry=4
SecretKey="linux"
if [[ $1 =~ ^[A-Za-z" "]+$ && $2 =~ ^[0-9]+$ ]]
then
while [ $MaxNoofEntry -gt $numofentry ]
do
numofentry=$(($numofentry + 1))
echo "Enter the secret key to enter, BE CAREFUL you have only $SecretKeyEntry attempts left: "
read secretKeyUserInput
SecretKeyEntry=$(($SecretKeyEntry - 1))
if [ $secretKeyUserInput == $SecretKey ]
then
echo "****************************************************************"
echo "****************************************************************"
echo "********** WELCOME $1 $2 ********************"
echo "********* CURRENT DATE IS $(date) ***************"
echo "****************************************************************"
echo "****************************************************************"
repeat()
{ echo "Guess the best football team out of these and enter the country code!"
echo "----------------------------------------------------------------"
echo " ***** COUNTRY ** CODE ******"
echo "----------------------------------------------------------------"
echo " ***** Brazil ** BRZ ******"
echo " ***** Argentina ** ARG ******"
echo " ***** Nepal ** NEP ******"
echo " ***** China ** CHI ******"
echo " ***** England ** ENG ******"
echo "****************************************************************"
echo "****************************************************************"
echo "Enter the country code"
read userSelectedTeam
echo "------------------------------------------"
bestFootTeam="NEP"
until [ $userSelectedTeam == $bestFootTeam ]
do
echo "SORRY! Wrong country Selected!!!"
echo "TRY AGAIN!!!!"
echo "Please choose another one: "
read userSelectedTeam
done
echo "OH YEAH! NICE ONE"
echo "The Nepal national football team represents Nepal in International
men's football, and is governed by the All Nepal Football Association.
A member of the Asian Football Confederation, the Nepalese football team
plays their home games at Dasarath Rangasala Stadium in Kathmandu."
echo "****************************************************************"
echo "Select any three players out of the following: "
echo "****************************************************************"
echo "-----------------------------------------------------------------"
echo " ** Player Code ** Player **"
echo "-----------------------------------------------------------------"
echo "** LM ** Lionel Messi **"
echo "** NJ ** Neymar Junior **"
echo "** KC ** Kiran Chemjong **"
echo "** ZZ ** Zheng Zhi **"
echo "** HK ** Harry Kane **"
echo "------------------------------------------------------------------"
echo "****************************************************************"
echo "Enter three of your favourite players's Player code and seperate them by space: "
players=("LM NJ KC ZZ HK")
until [[ ${#k} = 2 && "${players[@]}" =~ "${j}" && "${players[@]}" =~ "${k}" && "${players[@]}" =~ "${i}" && $i != $j && $i != $k && $j != $i && $j != $k && $k != $i && $k != $j ]]
do
echo -e "Select three Player's codes (Case sensitive) : \c"
read i j k
done
echo "********************************"
echo "************************************"
echo "Three players are selected"
echo "****************************************"
echo "********************************************"
echo "Choose your favourite player among them "
echo "*******************************************"
echo "********************************************"
select player in $i $j $k
do
if [ -z "$player" ]
then
echo "Please enter 1 or 2 or 3"
else
echo "You choose $player as your favourite player."
break
fi
done
i=""
j=""
k=""
if [ $player == LM ]
then
cat LM
elif [ $player == KC ]
then
cat KC
elif [ $player == NJ ]
then
cat NJ
else
echo " The program does not have any information of player you choose."
repeat
fi
function access()
{ echo "Do you want to start again????"
read userInpRepeatProgram
case "$userInpRepeatProgram" in
yes|y)
repeat
;;
no|n)
exit
;;
*)
echo "Enter Either yes or no!!!"
access
;;
esac
}
}
repeat
access
exit
fi
done
else
echo "Enter name and id in a proper way to proceed further."
fi