الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

هذا الجواب بس من يحب يكتب السوئل

بدأه jMustafa في 24 ديسمبر 2013 · 1 رد · 609 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

البرنامج عبارة عن لعبة تختار أسم وتعطيك حرف واحد و موقع الحرف في الأسم وأمت تكتب الأسم أذا كان الأسم الي كتبته صحيح تفوز

هذا الجواب

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


namespace ConsoleApplication5
{
    class Program
    {
        private static Path path = new Path();
        private static Messages messages = new Messages();

        static void Main(string[] args)
        {
            run();

            Console.WriteLine(messages.msg(12));
            Console.ReadKey();
        }


        private static void run()
        {
            bool runtheprogram = true;
            Console.WriteLine(messages.msg(0));
            Console.WriteLine(messages.msg(1));
            help();
            Console.WriteLine(messages.msg(9));
            while (runtheprogram)
            {
                path.settheprogram();
                
                Console.WriteLine(messages.msg(2),path.getnamechar());
                Console.WriteLine(messages.msg(3),path.getcharnumber());
                Console.WriteLine(messages.msg(4),path.getnamelenght());
                Console.Write(messages.msg(5));
                String userinput = Convert.ToString(Console.ReadLine());
                runtheprogram = game(userinput);
                answer();
            }
        }

        private static bool game(String userinput)
        {
            if (userinput == "1")
            {
                help();
            }
            if (userinput == "0")
            {
                exit();
            }
            else
            {
                if (userinput == path.getname())
                {
                    Console.WriteLine(messages.msg(7));
                }
                else
                {
                    Console.WriteLine(messages.msg(6));
                }
            }
            
            Console.WriteLine(messages.msg(11));
            Console.Write(messages.msg(8));
            
            userinput = Convert.ToString(Console.ReadLine());
            
            Console.WriteLine("\n");
            
            if (userinput == "y" || userinput == "Y")
                return true;
            if (userinput == "n" || userinput == "N")
                return false;
           
            return true;
        }


        private static void answer()
        {
            Console.WriteLine(messages.msg(13),path.getname());
            
        }


        private static void help()
        {
            Console.WriteLine(messages.msg(10));
        }

        
        private static void exit()
        {
            Environment.Exit(0);
        }

    }
}

messages class

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

namespace ConsoleApplication5
{
    class Messages
    {
        public String msg(int msgId)
        {

            switch (msgId)
            {

                case 0: return "Wellcom The Random Name Game";

                case 1: return "I will give one letter from a hidden name and the position of the letter and the lenght of the name.";

                case 2: return "This is the letter : {0}";

                case 3: return "This is the position of the letter : {0}";

                case 4: return "This is the lenght of the name : {0}";

                case 5: return "Gusse The Name : ";

                case 6: return "I win! \n";

                case 7: return "You win! \n";

                case 8: return "Would you like to play agian?";

                case 9: return "Help = 1 - Exit = 0";

                case 10: return "For example I would give "
                               + "This is the letter : u \n"
                               + "This is the position of the letter : 2 \n"
                               + "This is the lenght of the name : 7 \n"
                               + "Gusse The Name : Mustafa \n";

                case 11 : return "y or Y for Yes - n or N for No";

                case 12: return "Thanks A Lot For Trying The Game";

                case 13: return "The answer was : {0} \n";

                default: return "Program error, this program doesn't contine this further information";
            }


        }


    }
}

باقي الجواب أنا كتبت الرنامج في 2:30 س

 

 

الأسماء التي تحوية اللعبة

Dacian
Carson
Aric
Garan
Manyard
Kellan
Oscar
Nathan
Riley
Tave
Malik
Terrian

اللعبة في المرفق

 

 

ConsoleApplication5.zip

#2

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ConsoleApplication5

{

class Path

{

private class Sname

{

private String _name;

private Char _namechar;

private int _charnumber;

private int _namelenght;

private Random ran = new Random();

private static string[] names = {"Dacian"

, "Carson"

, "Aric"

, "Garan"

, "Manyard"

, "Kellan"

, "Oscar"

, "Nathan"

, "Riley"

, "Tave"

, "Malik"

, "Terrian"};

public String getname()

{

int which = 0;

int lenght = names.Length;

which = ran.Next(lenght);

_name = names[which];

return names[which];

}

public Char[] convertor(String name)

{

Char[] charname = name.ToCharArray();

return charname;

}

public Char namechar(Char[] charname)

{

int which = 0;

int lenght = charname.Length;

which = ran.Next(lenght);

_namechar = charname[which];

_charnumber = which + 1;

_namelenght = lenght;

return charname[which];

}

public String get_name()

{

return _name;

}

public Char get_namechar()

{

return _namechar;

}

public int get_charnumber()

{

return _charnumber;

}

public int get_namelenght()

{

return _namelenght;

}

}

private String name;

private Char namechar;

private int charnumber;

private int namelenght;

public void settheprogram()

{

Sname namebank = new Sname();

namebank.namechar(namebank.convertor(namebank.getname()));

name = namebank.get_name();

namechar = namebank.get_namechar();

charnumber = namebank.get_charnumber();

namelenght = namebank.get_namelenght();

}

public String getname() { return name; }

public Char getnamechar() { return namechar; }

public int getcharnumber() { return charnumber; }

public int getnamelenght() { return namelenght; }

}

}

تم تعديل هذه المشاركة بواسطة jMustafa في 26 ديسمبر 2013 في 19:32

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…