.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Generics >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

FLAMES GAMES in C#

Posted By:papsantony       Posted Date: August 12, 2010    Points: 10    Category: Generics    URL: http://www.dotnetspark.com  

FLAMES GAMES with C# sample example
 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str, str1;
            string gamestring = "FLAMES";

            string tempstr = null;

            int i, j, k, temp, total = 0;
            //char FINAL;

            char[] c1 = new char[50];
            char[] c2 = new char[50];
            Console.WriteLine("\t");
            for(i=0;i<=31;i++)
                Console.Write("*");
            Console.Write("WELCOME TO FLAMES");
            for (i = 0; i <= 30; i++)
                Console.Write("*");
            Console.WriteLine("");
            for (i = 0; i <= 31; i++)
                Console.Write("*");         
            for (i = 0; i <= 47; i++)
                Console.Write("*");
            Console.Write("\t ENTER THE FIRST STRING : ");
            str = Console.ReadLine();
            Console.Write("\t ENTER THE SECOND STRING: ");
            str1 = Console.ReadLine();

            for (i = 0; i <= str.Length - 1; i++)
            {
                c1[i] = str[i];
            }
            for (j = 0; j <= str1.Length - 1; j++)
            {
                c2[j] = str1[j];
            }

            for (i = 0; i <= str.Length - 1; i++)
            {

                for (j = 0; j <= str1.Length - 1; j++)
                {

                    if (c1[i] == c2[j])
                    {
                        c1[i] = '*';
                        c2[j] = '*';
                        goto te;
                    }

                }
            te:

                Console.WriteLine();
            }

          

            for (i = 0; i <= str.Length - 1; i++)
            {
                if (c1[i] != '*')
                {
                    total++;
                }
                
            }
            Console.WriteLine();
            for (j = 0; j <= str1.Length - 1; j++)
            {
                if (c2[j] != '*')
                {
                    total++;
                }
                
            }
            for (i = 0; i <= 31; i++)
                Console.Write("*");
            for (i = 0; i <= 47; i++)
                Console.Write("*");
            Console.WriteLine("\t\tCOUNTING NUMBER IS   " + total);
            for (i = 0; i <= 31; i++)
                Console.Write("*");
            for (i = 0; i <= 47; i++)
                Console.Write("*");
            Console.WriteLine(" GAME IS OVER ");
           
            
            k = 6;

            for(k=6;k>1;k--)
            {
               char[] c3 = new char[10];

                for (i = 1; i <= gamestring.Length; i++)
                {
                    c3[i] = gamestring[i-1];

                }

                if (total <= gamestring.Length)
                {
                    c3[total] = '*';
                    tempstr = "";
                    for (i = total + 1; i <= gamestring.Length; i++)
                    {

                        tempstr = tempstr + c3[i].ToString();
                    }
                    for (j = 1; j <= total - 1; j++)
                    {

                        tempstr = tempstr + c3[j].ToString();
                    }
                    gamestring = tempstr;
                }
                else
                {
                    temp = total % gamestring.Length;
                    if (temp == 0)
                    {
                        c3[gamestring.Length] = '*';
                        tempstr = "";
                        for (i = temp + 1; i < gamestring.Length; i++)
                        {

                            tempstr = tempstr + c3[i].ToString();
                        }

                        gamestring = tempstr;
                    }
                    else
                    {
                        c3[temp] = '*';


                        tempstr = "";
                        for (i = temp + 1; i <= gamestring.Length; i++)
                        {

                            tempstr = tempstr + c3[i].ToString();
                        }
                        for (j = 1; j <= temp - 1; j++)
                        {

                            tempstr = tempstr + c3[j].ToString();
                        }
                        gamestring = tempstr;
                    }

                }

               
            }

            //Console.WriteLine("the string is " + gamestring);
            switch (gamestring)
            {
                case "F": Console.WriteLine(" \t\t " + str + "\tAND\t" + str1 + "\tARE GOOD FRIENDS");
                    break;
                case "L": Console.WriteLine(" \t\t " + str + "\tAND\t" + str1 + "\tARE LOVERS");
                    break;
                case "A": Console.WriteLine(" \t\t " + str + "\tAND\t" + str1 + "\tONLY AFFECTION RELATIONSHIP");
                    break;
                case "M": Console.WriteLine(" \t\t " + str + "\tAND\t" + str1 + "\tARE MARRIED");
                    break;
                case "E": Console.WriteLine(" \t\t " + str + "\tAND\t" + str1 + "\tARE ENEMIES SO BECAREFUL ");
                    break;
                case "S": Console.WriteLine(" \t\t " + str + "\tAND\t" + str1 + "\tARE  SISTER");
                    break;
                default: Console.WriteLine(" GAME IS OVER ");
                    break;

            }
            for (i = 0; i <= 31; i++)
                Console.Write("*");
            for (i = 0; i <= 47; i++)
                Console.Write("*");

            Console.WriteLine(" \t\t\tDreams comes true\t\t\t ");

            Console.ReadLine();







        }
    }
}



     

Further Readings:

Responses
Author: kevin         Company URL: http://www.dotnetspark.com
Posted Date: September 09, 2012

Your Code is wrong. the counting of it is not right try this code


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace flames_daw
{
class Program
{
static void Main(string[] args)
{

int ctr,ctr1;
string name1, name2;
string sameletter="";
int numberofsameletter;
string answer1 = "", answer2 = "";
int numberofallletters;
int totalnumbers;


Console.WriteLine("Enter First Name");
name1 = Console.ReadLine ();
Console.WriteLine("Enter Second Name");
name2 = Console.ReadLine ();
numberofallletters = name1.Length + name2.Length;
Console.WriteLine("numbers of letter;" + numberofallletters);


for (ctr = 0; ctr <= name1.Length - 1; ++ctr)
{
answer1 = name1.Substring(ctr, 1);
for (ctr1 = 0; ctr1 <= name2.Length - 1; ++ctr1)
{
answer2 = name2.Substring(ctr1, 1);
if (answer1 == answer2)
{
sameletter = sameletter + (answer1 + answer2) ;
}
}
}

numberofsameletter = sameletter.Length;
Console.WriteLine("number of same; " + numberofsameletter);
totalnumbers = numberofallletters - numberofsameletter;
Console.WriteLine("total count; " + totalnumbers);

if (totalnumbers % 6 == 1)
Console.WriteLine("Friends");
else if (totalnumbers % 6 == 2)
Console.WriteLine("Lovers");
else if (totalnumbers % 6 == 3)
Console.WriteLine("Afair");
else if (totalnumbers % 6 == 4)
Console.WriteLine("maried");
else if (totalnumbers % 6 == 5)
Console.WriteLine("Enemies");
else if (totalnumbers % 6 == 0)
Console.WriteLine("Sweet");

}
}
}


Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend