I am new to C# and I am trying to build console quiz.
Here is my problem:
For every option removed I have to reduce one option (let's say the total points are 100).
If one option is removed I need to reduce the total points by 25 (i.e now the total points will be 75).
JSON data:
{
"question": [
{
"level": "Easy",
"cat": "sports",
"description": "Who is the Highest run getter in 2019",
"Option1": "Rohit Sharma",
"Option2": "Virat Kohli",
"Option3": "Kl Rahul",
"Option4": "S Dhawan",
"Answer":"1"
}]
}
Program:
using System;
using System.Timers;
namespace CProgram
{
class EasyQuestion
{
private string mLevel;
private string mCat;
private string mDescription;
private string mOption1;
private string mOption2;
private string mOption3;
private string mOption4;
private string mAnswer;
public string MDescription { get => mDescription; }
public string MOption1 { get => mOption1; }
public string MOption2 { get => mOption2; }
public string MOption3 { get => mOption3; }
public string MOption4 { get => mOption4; }
public string MAnswer { get => mAnswer; }
public string MLevel { get => mLevel; }
public string MCat { get => mCat; }
public static int sQcount=1;
public int sPlayerScore=0;
public int mNoOfQuesAnswerd=0;
static Timer questionTimer = new Timer(60000) ;
private static void QuestionTimer_Elapsed(object sender, ElapsedEventArgs e)
{
Console.WriteLine("Time up!");
System.Console.WriteLine("Lets Move on to Next Question");
questionTimer.Stop();
}
public EasyQuestion(string level,string cat,string description,string Option1,string Option2,string Option3,string Option4,string Answer)
{
this.mLevel=level;
this.mCat=cat;
this.mDescription=description;
this.mOption1=Option1;
this.mOption2=Option2;
this.mOption3=Option3;
this.mOption4=Option4;
this.mAnswer=Answer;
}
public EasyQuestion()
{
}
public void AskEasyQues(EasyQuestion easyQuestion)
{
System.Console.WriteLine("Here is Your:"+sQcount+" Question:");
System.Console.WriteLine("***********************************");
System.Console.WriteLine("Question is of The Category:"+easyQuestion.MCat);
System.Console.WriteLine("***********************************");
System.Console.WriteLine(easyQuestion.MDescription);
System.Console.WriteLine("--------------------------------------");
System.Console.WriteLine("1:"+easyQuestion.MOption1+" "+"2:"+easyQuestion.MOption2);
System.Console.WriteLine();
System.Console.WriteLine("3:"+easyQuestion.MOption3+" "+"4:"+easyQuestion.MOption4);
System.Console.WriteLine();
questionTimer.Elapsed += QuestionTimer_Elapsed;
questionTimer.Enabled = true;
questionTimer.Start();
System.Console.WriteLine("Enter your Choice:");
/*for (int a = 60; a >= 0; a--)
{
Console.Write("\rGenerating Preview in {0:00}", a);
System.Threading.Thread.Sleep(1000);
} */
string ans=Console.ReadLine();
if(ans==easyQuestion.MAnswer)
{
questionTimer.Stop();
mNoOfQuesAnswerd++;
System.Console.WriteLine();
System.Console.WriteLine("------Well Played Champion!!!!!!-----");
sPlayerScore=sPlayerScore+100;
}
else
{
System.Console.WriteLine();
System.Console.WriteLine("------Wrong Choice Lets Move On--------");
}
System.Console.WriteLine();
System.Console.WriteLine("Press any Key To Continue For Next Question");
Console.ReadLine();
System.Console.WriteLine();
System.Console.WriteLine("----------------------------");
sQcount=sQcount+1;
Console.Clear();
}
}
}
I have a timer of 60 seconds and I have to remove an option every 15 seconds.