So I have a bool method that checks if the user has a club membership, then I have another bool method which is supposed to tell what's supposed to be printed if the user does have a membership and play the little game to check if the user wins a prize. The problem is, when I run the program it prints out the "Welcome to the VIP only, sir." twice and skips the rest of the code, so what can I do to fix this issue.
static void Main(string[] args)
{
LoyaltyDiscount();
EnterContest(RandomClass);
}
private static bool LoyaltyDiscount()
{
string input;
Write("\nAre you a member of our Futility Club frequent shopper program? ('Y' if yes) ");
input = ReadLine().ToUpper();
if(input == "YES" || input == "Y")
{
//if user does have a club membership
WriteLine("Welcome to the VIP only, sir.");
return true;
}
else
{
//if user does not have a club membership
WriteLine("Thats okay, we still appreciate your purchase.");
return false;
}
}
private static bool EnterContest(Random chanceGenerator)
{
string input = LoyaltyDiscount().ToString();
int randomNumber;
const int gameMin = 1;
const int gameMax = 10;
Random RandomClass = new Random();
randomNumber = RandomClass.Next(gameMin, gameMax);
if ((input == "YES") || (input == "Y"))
{
//prompt if user answers "yes" to if they a club membership and ask to play the game
Write("Do you want to play a game and win a prize?");
int.TryParse(ReadLine(), out int guess);
if (guess < gameMin || guess > gameMax)
{
//if user guesses number out of boundary
WriteLine("Guess out of boundary");
return false;
}
if (guess == randomNumber)
{
//if user guesses correct number
WriteLine("Correct guess.");
}
else
{
//if user guesses wrong number
Write("Wrong guess.");
return false;
}
}
return true;
}
The goal is to get the user input from LoyaltyDiscount() method and ask if the user does have a membership, then if the user does have a membership, use it in EnterContest() method only if they have a membership.