armin20
سه شنبه 05 آذر 1387, 12:41 عصر
میشه کمک کنین بگین مشکل برنامم چیه؟
using System;
using System.Collections.Generic;
using System.Text;
using System.Timers;
using System.IO;
namespace Project2
{
class Program
{
static Timer t = new Timer(1000);
static int count = 0;
static Easy e = new Easy();
static Medium m = new Medium();
static Hard h = new Hard();
static int choice = 0;
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine("Select your choice : ");
Console.ForegroundColor = ConsoleColor.Gray; ;
Console.WriteLine(" 1. Easy");
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine(" 2. Medium");
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine(" 3. Hard");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("Your choice : ");
choice = Convert.ToInt32(Console.ReadLine());
t.Elapsed += new ElapsedEventHandler(show);
t.Start();
Console.ReadKey();
}
static void show(object sender, ElapsedEventArgs e1)
{
switch (choice)
{
case 1:
{
Console.Clear();
e.Display();
count++;
if (count == 3)
{
Console.Clear();
}
e.check();
}
break;
case 2:
{
Console.Clear();
m.Display();
count++;
if (count == 3)
{
Console.Clear();
}
m.check();
}
break;
case 3:
{
Console.Clear();
h.Display();
count++;
if (count == 3)
{
Console.Clear();
}
h.check();
}
break;
default:
Console.WriteLine("Invalid choice");
break;
}
}
}//end class
class Easy
{
public int level = 0;
static Random r = new Random();
static char a = Convert.ToChar(r.Next(97, 123));
static char b = Convert.ToChar(r.Next(65, 91));
static char c = Convert.ToChar(r.Next(97, 123));
static string word = Convert.ToString(a) + Convert.ToString(b) + Convert.ToString(c);
static string uword = "";
public void Display()
{
Console.SetCursorPosition(32, 10);
Console.WriteLine("{0} {1} {2}", a, b, c);
}
public void check()
{
uword = Console.ReadLine();
if (uword == word)
{
while (uword== word)
{
a = Convert.ToChar(r.Next(97, 123));
b = Convert.ToChar(r.Next(65, 91));
c = Convert.ToChar(r.Next(97, 123));
word = Convert.ToString(a) + Convert.ToString(b) + Convert.ToString(c);
Console.Clear();
Console.SetCursorPosition(32, 10);
Console.WriteLine("{0} {1} {2}", a, b, c);
Console.SetCursorPosition(32, 12);
uword = Console.ReadLine();
level++;
}
}
if (uword != word)
{
Console.Clear();
Console.SetCursorPosition(32, 10);
Console.WriteLine("Los!!");
Console.Write("Enter score is {0} please enter your name: ", level);
string name = Console.ReadLine();
StreamWriter strm = new StreamWriter(File.Create("Score.txt"));
strm.Write(name + "\t" + level);
strm.Close();
}
}
}
class Medium
{
int level = 0;
static Random r = new Random();
static char a = Convert.ToChar(r.Next(97, 123));
static char b = Convert.ToChar(r.Next(49, 57));
static char c = Convert.ToChar(r.Next(65, 91));
static string word = Convert.ToString(a) + Convert.ToString(b) + Convert.ToString(c);
public void Display()
{
Console.SetCursorPosition(32, 10);
Console.WriteLine("{0} {1} {2}", a, b, c);
}
public void check()
{
Console.SetCursorPosition(32, 12);
string uword = Console.ReadLine();
if (uword == word)
{
while (uword== word)
{
a = Convert.ToChar(r.Next(97, 123));
b = Convert.ToChar(r.Next(49, 57));
c = Convert.ToChar(r.Next(65, 91));
word = Convert.ToString(a) + Convert.ToString(b) + Convert.ToString(c);
level++;
Console.Clear();
Console.SetCursorPosition(32, 10);
Console.WriteLine("{0} {1} {2}", a, b, c);
Console.SetCursorPosition(32, 12);
uword = Console.ReadLine();
}
}
if (uword != word)
{
Console.Clear();
Console.SetCursorPosition(32, 10);
Console.WriteLine("Los!!");
Console.Write("Enter score is {0} please enter your name: ", level);
string name = Console.ReadLine();
StreamWriter strm = new StreamWriter(File.Create("Score4Medium.txt"));
strm.Write(name + "\t" + level);
strm.Close();
}
}
}
class Hard
{
int level = -1;
static Random r = new Random();
static char a = Convert.ToChar((r.Next(97, 123)));
static char b = Convert.ToChar((r.Next(65, 91)));
static char c = Convert.ToChar((r.Next(48, 58)));
static string word =Convert.ToString(a)+Convert.ToString(b)+Convert.T oString(c);
string uword = "";
public void Display()
{
Console.SetCursorPosition(32, 10);
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("{0} ", a);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("{0} ", b);
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("{0} ", c);
}
public void check()
{
Console.SetCursorPosition(32, 12);
Console.Write("chars: ");
string ch1 = Console.ReadLine();
Console.Clear();
Console.SetCursorPosition(32, 12);
Console.Write("First colorr: ");
string c1 = Console.ReadLine();
Console.Clear();
Console.SetCursorPosition(32, 12);
Console.Write("Second colorr: ");
string c2 = Console.ReadLine();
Console.Clear();
Console.SetCursorPosition(32, 12);
Console.Write("Third colorr: ");
string c3 = Console.ReadLine();
if (ch1 == word && c1 == "b" && c2 == "y" && c3 == "r")
{
do
{
a = Convert.ToChar(r.Next(97, 123));
b = Convert.ToChar(r.Next(65, 91));
c = Convert.ToChar(r.Next(48, 58));
word = Convert.ToString(a) + Convert.ToString(b) + Convert.ToString(c);
Console.Clear();
Console.SetCursorPosition(32, 10);
string color = "";
for (int j = 0; j < word.Length; j++)
{
int rc = r.Next(1, 4);
color += Convert.ToString(rc);
switch (rc)
{
case 1:
Console.ForegroundColor = ConsoleColor.Blue;
break;
case 2:
Console.ForegroundColor = ConsoleColor.Red;
break;
case 3:
Console.ForegroundColor = ConsoleColor.Green;
break;
case 4:
Console.ForegroundColor = ConsoleColor.Yellow;
break;
}
Console.Write(word[j]);
}
Console.WriteLine();
Console.SetCursorPosition(32, 12);
uword = Console.ReadLine();
Console.Clear();
Console.SetCursorPosition(0, 10);
Console.Write("Enter colors in order(r for red,b for blue,g for green,y for yelow): ");
string colors = Console.ReadLine();
level++;
} while (uword == word);
}
if (uword != word)
{
Console.Clear();
Console.SetCursorPosition(32, 10);
Console.WriteLine("Los!!");
//Score s = new Score();
//s.GetNameScore();
Console.Write("Enter score is {0} please enter your name: ", level);
string name = Console.ReadLine();
StreamWriter strm = new StreamWriter(File.Create("Score4Hard.txt"));
strm.Write(name + "\t" + level);
strm.Close();
}
}
}
}//end nameSpace
using System;
using System.Collections.Generic;
using System.Text;
using System.Timers;
using System.IO;
namespace Project2
{
class Program
{
static Timer t = new Timer(1000);
static int count = 0;
static Easy e = new Easy();
static Medium m = new Medium();
static Hard h = new Hard();
static int choice = 0;
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine("Select your choice : ");
Console.ForegroundColor = ConsoleColor.Gray; ;
Console.WriteLine(" 1. Easy");
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine(" 2. Medium");
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine(" 3. Hard");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("Your choice : ");
choice = Convert.ToInt32(Console.ReadLine());
t.Elapsed += new ElapsedEventHandler(show);
t.Start();
Console.ReadKey();
}
static void show(object sender, ElapsedEventArgs e1)
{
switch (choice)
{
case 1:
{
Console.Clear();
e.Display();
count++;
if (count == 3)
{
Console.Clear();
}
e.check();
}
break;
case 2:
{
Console.Clear();
m.Display();
count++;
if (count == 3)
{
Console.Clear();
}
m.check();
}
break;
case 3:
{
Console.Clear();
h.Display();
count++;
if (count == 3)
{
Console.Clear();
}
h.check();
}
break;
default:
Console.WriteLine("Invalid choice");
break;
}
}
}//end class
class Easy
{
public int level = 0;
static Random r = new Random();
static char a = Convert.ToChar(r.Next(97, 123));
static char b = Convert.ToChar(r.Next(65, 91));
static char c = Convert.ToChar(r.Next(97, 123));
static string word = Convert.ToString(a) + Convert.ToString(b) + Convert.ToString(c);
static string uword = "";
public void Display()
{
Console.SetCursorPosition(32, 10);
Console.WriteLine("{0} {1} {2}", a, b, c);
}
public void check()
{
uword = Console.ReadLine();
if (uword == word)
{
while (uword== word)
{
a = Convert.ToChar(r.Next(97, 123));
b = Convert.ToChar(r.Next(65, 91));
c = Convert.ToChar(r.Next(97, 123));
word = Convert.ToString(a) + Convert.ToString(b) + Convert.ToString(c);
Console.Clear();
Console.SetCursorPosition(32, 10);
Console.WriteLine("{0} {1} {2}", a, b, c);
Console.SetCursorPosition(32, 12);
uword = Console.ReadLine();
level++;
}
}
if (uword != word)
{
Console.Clear();
Console.SetCursorPosition(32, 10);
Console.WriteLine("Los!!");
Console.Write("Enter score is {0} please enter your name: ", level);
string name = Console.ReadLine();
StreamWriter strm = new StreamWriter(File.Create("Score.txt"));
strm.Write(name + "\t" + level);
strm.Close();
}
}
}
class Medium
{
int level = 0;
static Random r = new Random();
static char a = Convert.ToChar(r.Next(97, 123));
static char b = Convert.ToChar(r.Next(49, 57));
static char c = Convert.ToChar(r.Next(65, 91));
static string word = Convert.ToString(a) + Convert.ToString(b) + Convert.ToString(c);
public void Display()
{
Console.SetCursorPosition(32, 10);
Console.WriteLine("{0} {1} {2}", a, b, c);
}
public void check()
{
Console.SetCursorPosition(32, 12);
string uword = Console.ReadLine();
if (uword == word)
{
while (uword== word)
{
a = Convert.ToChar(r.Next(97, 123));
b = Convert.ToChar(r.Next(49, 57));
c = Convert.ToChar(r.Next(65, 91));
word = Convert.ToString(a) + Convert.ToString(b) + Convert.ToString(c);
level++;
Console.Clear();
Console.SetCursorPosition(32, 10);
Console.WriteLine("{0} {1} {2}", a, b, c);
Console.SetCursorPosition(32, 12);
uword = Console.ReadLine();
}
}
if (uword != word)
{
Console.Clear();
Console.SetCursorPosition(32, 10);
Console.WriteLine("Los!!");
Console.Write("Enter score is {0} please enter your name: ", level);
string name = Console.ReadLine();
StreamWriter strm = new StreamWriter(File.Create("Score4Medium.txt"));
strm.Write(name + "\t" + level);
strm.Close();
}
}
}
class Hard
{
int level = -1;
static Random r = new Random();
static char a = Convert.ToChar((r.Next(97, 123)));
static char b = Convert.ToChar((r.Next(65, 91)));
static char c = Convert.ToChar((r.Next(48, 58)));
static string word =Convert.ToString(a)+Convert.ToString(b)+Convert.T oString(c);
string uword = "";
public void Display()
{
Console.SetCursorPosition(32, 10);
Console.ForegroundColor = ConsoleColor.Blue;
Console.Write("{0} ", a);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("{0} ", b);
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("{0} ", c);
}
public void check()
{
Console.SetCursorPosition(32, 12);
Console.Write("chars: ");
string ch1 = Console.ReadLine();
Console.Clear();
Console.SetCursorPosition(32, 12);
Console.Write("First colorr: ");
string c1 = Console.ReadLine();
Console.Clear();
Console.SetCursorPosition(32, 12);
Console.Write("Second colorr: ");
string c2 = Console.ReadLine();
Console.Clear();
Console.SetCursorPosition(32, 12);
Console.Write("Third colorr: ");
string c3 = Console.ReadLine();
if (ch1 == word && c1 == "b" && c2 == "y" && c3 == "r")
{
do
{
a = Convert.ToChar(r.Next(97, 123));
b = Convert.ToChar(r.Next(65, 91));
c = Convert.ToChar(r.Next(48, 58));
word = Convert.ToString(a) + Convert.ToString(b) + Convert.ToString(c);
Console.Clear();
Console.SetCursorPosition(32, 10);
string color = "";
for (int j = 0; j < word.Length; j++)
{
int rc = r.Next(1, 4);
color += Convert.ToString(rc);
switch (rc)
{
case 1:
Console.ForegroundColor = ConsoleColor.Blue;
break;
case 2:
Console.ForegroundColor = ConsoleColor.Red;
break;
case 3:
Console.ForegroundColor = ConsoleColor.Green;
break;
case 4:
Console.ForegroundColor = ConsoleColor.Yellow;
break;
}
Console.Write(word[j]);
}
Console.WriteLine();
Console.SetCursorPosition(32, 12);
uword = Console.ReadLine();
Console.Clear();
Console.SetCursorPosition(0, 10);
Console.Write("Enter colors in order(r for red,b for blue,g for green,y for yelow): ");
string colors = Console.ReadLine();
level++;
} while (uword == word);
}
if (uword != word)
{
Console.Clear();
Console.SetCursorPosition(32, 10);
Console.WriteLine("Los!!");
//Score s = new Score();
//s.GetNameScore();
Console.Write("Enter score is {0} please enter your name: ", level);
string name = Console.ReadLine();
StreamWriter strm = new StreamWriter(File.Create("Score4Hard.txt"));
strm.Write(name + "\t" + level);
strm.Close();
}
}
}
}//end nameSpace