Beispiel #1
0
        //Reads through movie inventory and removed inventory and returns movie that matches id parameter
        public static Movie GetMovie(int id)
        {
            MovieFile mf = new MovieFile();

            Movie[] inv = mf.ReadFile();
            for (int i = 0; i < inv.Length; i++)
            {
                if (inv[i].GetMovieID() == id)
                {
                    return(inv[i]);
                }
            }

            RemovedFile rf = new RemovedFile();

            Movie[] rem = rf.ReadFile();
            for (int i = 0; i < rem.Length; i++)
            {
                if (rem[i].GetMovieID() == id)
                {
                    return(rem[i]);
                }
            }

            Console.WriteLine("\tError: Movie with ID = " + id + " Not Found");
            Movie blankMovie = new Movie();

            return(blankMovie);
        }
Beispiel #2
0
        //Removes movie from inventory
        public static void Delete(String line)
        {
            MovieFile mf = new MovieFile();

            Movie[] inv = mf.ReadFile();

            int id    = int.Parse(line.Split('#')[0]);
            int index = Program.GetMovieIndex(inv, id);

            inv[index].SetStock();
            Movie removie = inv[index];

            inv = Program.RemoveMovieFromArray(inv, inv[index]);
            mf.DecrementCount();
            mf.WriteFile(inv);

            RemovedFile rf = new RemovedFile();

            Movie[] oldRemoved = rf.ReadFile();
            rf.IncrementCount();
            int count = rf.GetCount();

            Movie[] updatedRemoved = new Movie[count];

            for (int i = 0; i < count - 1; i++)
            {
                updatedRemoved[i] = oldRemoved[i];
            }
            updatedRemoved[count - 1] = removie;
            Console.WriteLine($"\nRemoved movie: {removie.ReadString()}");
            rf.WriteFile(updatedRemoved);
        }
Beispiel #3
0
        //Reads through movie inventory and removed inventory and returns the next movie id
        public static int GetNextID()
        {
            int max = 0;

            MovieFile mf = new MovieFile();

            Movie[] inv = mf.ReadFile();
            for (int i = 0; i < inv.Length; i++)
            {
                if (inv[i].GetMovieID() > max)
                {
                    max = inv[i].GetMovieID();
                }
            }

            RemovedFile rf = new RemovedFile();

            Movie[] rem = rf.ReadFile();
            for (int i = 0; i < rem.Length; i++)
            {
                if (rem[i].GetMovieID() > max)
                {
                    max = rem[i].GetMovieID();
                }
            }

            return(max + 1);
        }