Ara

OTOBÜS OTOMASYONU

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

namespace otobusotomasyon
{
    class Program
    {
        static string[] yolcu = new string[34];


        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.White;

            for (int i = 0; i < yolcu.Length; i++)
            {
                yolcu[i] = null;
            }
            string devamEt = "", devam;
            string yeniYolcu = "";
            while (devamEt != "1")
            {
                while (true)
                {
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.WriteLine("\nÇıkmak için              =>1" +
                                        "\nDevam için               =>2" +
                                        "\nButun yolcu listesi için =>3" +
                                        "\nBoş koltuk listesi için  =>4");

                    devam = Console.ReadLine();
                    if (devam == "1")
                    {
                        devamEt = "1";
                        break;
                    }
                    else if (devam == "2")
                    {
                        devamEt = "";
                        break;
                    }
                    else if (devam == "3")
                        bosKoltukListele();
                    else if (devam == "4")
                        butunKoltuklarıListele();
                }
                if (devamEt != "1")
                {
                    bool isimYenidenAl = true;
                    while (isimYenidenAl)
                    {
                        yeniYolcu = isim();
                        if (isimUygunMU(yeniYolcu))
                            isimYenidenAl = false;
                        else
                            Console.WriteLine("\nİsminiz harflerden oluşmalı...\n");

                    }

                    Console.WriteLine("Kaç numaralı koltugu istiyosunuz?  <=");
                    int istenilenKoltuk = Convert.ToInt16(Console.ReadLine()) - 1;
                    bool koltukUygun = false;
                    if (koltukBosMu(istenilenKoltuk))
                    {
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine((istenilenKoltuk + 1) + " numaralı koltugu " +
                        yeniYolcu + " satın almıstır");
                        yolcu[istenilenKoltuk] = yeniYolcu;
                    }
                    else
                        while (!koltukUygun)
                        {
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("\nİstemis oldugunuz koltuk dolu\n");
                            Console.ForegroundColor = ConsoleColor.White;
                            Console.WriteLine("\nBos koltukları listelemek icin     =>1" +
                                              "\nbutun koltukları listelemek için   =>2");
                            string secim = Console.ReadLine();
                            if (secim == "1")
                                bosKoltukListele();
                            else if (secim == "2")
                                butunKoltuklarıListele();
                            while (true)
                            {
                                Console.WriteLine("\nBoş bir koltuk seçiniz \t: ");
                                istenilenKoltuk = Convert.ToInt16(Console.ReadLine()) - 1;
                                if (koltukBosMu(istenilenKoltuk))
                                {
                                    koltukUygun = true;
                                    break;
                                }
                            }
                            Console.ForegroundColor = ConsoleColor.Green;

                            Console.WriteLine((istenilenKoltuk + 1) + " numaralı koltugu " +
                            yeniYolcu + " satın almıstır");
                            yolcu[istenilenKoltuk] = yeniYolcu;

                        }
                }

            }
        }

        static void baslik()
        {
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("\n\t\tKoltuk No:\tYolcu:\t\tKoltuk No:\tYolcu:");
            Console.WriteLine("\t\t---------\t------\t\t---------\t------");

        }

        static string isim()
        {
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Adınız ve soyadinizi giriniz\t: ");
            return Console.ReadLine();
        }

        static bool isimUygunMU(string adSoyad)
        {
            bool durum = true;
            for (int i = 0; i < adSoyad.Length; i++)
                if (!(char.IsLetter(adSoyad[i]) || adSoyad[i] == ' '))
                {
                    durum = false;
                    break;
                }

            return durum;
        }

        static bool koltukBosMu(int koltukNo)
        {
            if (yolcu[koltukNo] == null)
                return true;
            else return false;
        }
        static void bosKoltukListele()
        {
            baslik();
            for (int i = 0; i < yolcu.Length; i += 2)
            {
                if (yolcu[i] == null)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write("\t\t   " + (i + 1) + "." + "\t\tBOŞ" + "\t\t");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("\t\t   " + (i + 1) + "." + "\t\tDOLU" + "\t\t");
                }
                if (yolcu[i + 1] == null)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write((i + 2) + "." + "\t\tBOŞ");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write((i + 2) + "." + "\t\tDOLU");
                }
                Console.WriteLine("");
            }
            Console.ForegroundColor = ConsoleColor.White;
        }

        static void butunKoltuklarıListele()
        {
            Console.ForegroundColor = ConsoleColor.White;
            baslik();
            for (int i = 0; i < yolcu.Length; i += 2)
            {
                if (yolcu[i] == null)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write("\t\t   " + (i + 1) + "." + "\t\tBOŞ" + "\t\t");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("\t\t   " + (i + 1) + "." + "\t\t" + yolcu[i] + "\t");
                }
                if (yolcu[i + 1] == null)
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write((i + 2) + "." + "\t\tBOŞ");
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write((i + 2) + "." + "\t\t" + yolcu[i + 1]);
                }
                Console.WriteLine("");
            }
        }
    }
}