Example #1
0
        public void AddThreate()
        {
            Theatre T1 = new Theatre();

            Console.WriteLine("Enter Theatre Name: ");
            T1.TheatreName = Console.ReadLine();
            if (T1.TheatreName != "")
            {
                Theatres.Add(T1);
                Console.WriteLine("Theatre named: " + T1.TheatreName + " added.");
            }
            else
            {
                Console.WriteLine("Theatre name cannot be null.");
            }
        }
Example #2
0
        public bool UpdateThreatre()
        {
            Theatre T2 = new Theatre();

            Console.WriteLine("Enter the name of Theatre to be updated: ");
            T2.TheatreName = Console.ReadLine();
            int[] indx = Enumerable.Repeat(-1, Theatres.Count).ToArray();
            int   i    = 0;

            if (T2.TheatreName != "")
            {
                foreach (Theatre t in Theatres)
                {
                    if (t.TheatreName == T2.TheatreName)
                    {
                        indx[i] = Theatres.IndexOf(t);
                        i++;
                    }
                }
                if (i != 0)
                {
                    Console.WriteLine("Enter New Theatre Name: ");
                    T2.TheatreName = Console.ReadLine();
                    foreach (int j in indx)
                    {
                        if (j != -1)
                        {
                            Theatres.RemoveAt(j);
                            Theatres.Insert(j, T2);
                        }
                    }
                    Console.WriteLine("Theatre name: " + T2.TheatreName + " updated.");
                    return(true);
                }
                else
                {
                    Console.WriteLine("Theatre not found.");
                    return(true);
                }
            }
            else
            {
                Console.WriteLine("Theatre name cannot be null.");
                return(false);
            }
        }