//Adds movie to inventory public static void Add(String line) { String[] d = line.Split('#'); bool stock; if (d[4] == "yes") { stock = true; } else { stock = false; } Movie movieToAdd = new Movie(int.Parse(d[0]), d[1], d[2], int.Parse(d[3]), stock); MovieFile mf = new MovieFile(); Movie[] oldInv = mf.ReadFile(); mf.IncrementCount(); int count = mf.GetCount(); Movie[] updatedInventory = new Movie[count]; //Assigns updatedInventory movies to oldInv movies (thru count - 1). //Assigns last value of updatedInventory to movieToAdd and writes moviefile with updatedInventory. for (int i = 0; i < count - 1; i++) { updatedInventory[i] = oldInv[i]; } updatedInventory[count - 1] = movieToAdd; Console.WriteLine($"\nAdded movie: {movieToAdd.ReadString()}"); mf.WriteFile(updatedInventory); }
//Prints movies in stock public static void StockedMovies() { Console.Clear(); Console.WriteLine("\nIN STOCK MOVIES\n"); MovieFile mf = new MovieFile(); Movie[] inv = mf.ReadFile(); for (int i = 0; i < mf.GetCount(); i++) { if (inv[i].GetStock()) { Console.WriteLine(inv[i].ReadString()); } } }