Here's my messy code hand picked from Visual Studio, do what ever you want with it. The application is made on 1 single C# file.
- using System;
using System.Text;
using System.Xml;
namespace ConsoleApp3
{
class Program
{
public static void Main(string[] args)
{
reset:
string appName = "Multiplication Game";
string appVer = "1.0.1";
string appAuth = "jytehdev";
Console.WriteLine(appName + ": Version " + appVer + " by " + appAuth);
Console.WriteLine("Patch Notes: Scoring system now added!");
XmlTextReader reader = new XmlTextReader("test.xml");
Console.Write("The lowest possible number of the multiplication is: ");
int lowlimit = Convert.ToInt32(Console.ReadLine());
Console.Write("The highest possible number of the multiplication is: ");
int highlimit = Convert.ToInt32(Console.ReadLine());
int score = 0;
start:
Random rnd = new Random();
int num1 = rnd.Next(lowlimit, highlimit + 1);
int num2 = rnd.Next(lowlimit, highlimit + 1);
Console.WriteLine("What is " + num1 + " x " + num2);
int answer = Convert.ToInt32(Console.ReadLine());
if (answer == num1 * num2)
{
int responseindex1 = rnd.Next(1, 4);
switch (responseindex1)
{
case 1:
Console.WriteLine("Ur right");
break;
case 2:
Console.WriteLine("Good job");
break;
default:
Console.WriteLine("Nice");
break;
}
score += 1;
Console.WriteLine("Your score is " + score);
}
else if (answer == 0)
{
Environment.Exit(0);
}
else
{
int diff = Math.Abs(answer - (num1 * num2));
if (diff == 1)
{
Console.WriteLine("Really close \nYour final score is " + score);
Console.WriteLine("To reset the game press 'Enter'.");
XmlWriter xmlWriter = XmlWriter.Create("lastrecordedscore.xml");
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("lastrecordedscore");
xmlWriter.WriteString(Convert.ToString(score));
xmlWriter.WriteEndDocument();
xmlWriter.Close();
Console.ReadKey();
Console.Clear();
goto reset;
}
else if (diff <= 10)
{
Console.WriteLine("Eh, ur getting there \nYour final score is " + score);
Console.WriteLine("To reset the game press 'Enter'.");
XmlWriter xmlWriter = XmlWriter.Create("lastrecordedscore.xml");
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("lastrecordedscore");
xmlWriter.WriteString(Convert.ToString(score));
xmlWriter.WriteEndDocument();
xmlWriter.Close();
Console.ReadKey();
Console.Clear();
goto reset;
}
else
{
Console.WriteLine("Not even close \nYour final score is " + score);
Console.WriteLine("To reset the game press 'Enter'.");
XmlWriter xmlWriter = XmlWriter.Create("lastrecordedscore.xml");
xmlWriter.WriteStartDocument();
xmlWriter.WriteStartElement("lastrecordedscore");
xmlWriter.WriteString(Convert.ToString(score));
xmlWriter.WriteEndDocument();
xmlWriter.Close();
Console.ReadKey();
Console.Clear();
goto reset;
}
}
Console.ReadKey();
Console.Clear();
goto start;
}
}
}
