Ejemplo n.º 1
0
        public void CheckOutMenu(List <string> students, DVD dvd1, DVD dvd2, DVD dvd3, Book book1, Book book2, Book book3, Magazine mags1, Magazine mags2, Magazine mags3)
        {
            while (true)
            {
                string filename = StudentAccountsListForCheckOutsandIns(students);

                PrintStudentFile(filename);

                Console.WriteLine("Enter a letter to select the type of resource you want to check out: ");
                Console.WriteLine("A - Book");
                Console.WriteLine("B - DVD");
                Console.WriteLine("C - Magazine");

                string input = Console.ReadLine().ToUpper();

                switch (input)
                {
                case "A":
                    string bookfilecontent = Book.BookCheckOutResource(book1, book2, book3);
                    WriteStudentFile(filename, bookfilecontent);
                    break;

                case "B":
                    string DVDfilecontent = DVD.DVDCheckOutResource(dvd1, dvd2, dvd3);
                    WriteStudentFile(filename, DVDfilecontent);
                    break;

                case "C":
                    string magfilecontent = Magazine.MagCheckOutResource(mags1, mags2, mags3);
                    WriteStudentFile(filename, magfilecontent);
                    break;

                default:
                    continue;
                }
                break;
            }
        }
Ejemplo n.º 2
0
        public static string MagCheckOutResource(Magazine mags1, Magazine mags2, Magazine mags3)
        {
            StringBuilder sb = new StringBuilder();

            Console.Clear();
            Console.WriteLine("{0} - Status: {1}", mags1.Title, mags1.Status);
            Console.WriteLine("{0} - Status: {1}", mags2.Title, mags2.Status);
            Console.WriteLine("{0} - Status: {1}", mags3.Title, mags3.Status);

            Console.WriteLine("\n\nEnter the name of the resource you want to check out: ");
            string input = Console.ReadLine();

            if (input.Equals(mags1.Title, StringComparison.CurrentCultureIgnoreCase))
            {
                if (mags1.Status == "Available")
                {
                    mags1.Status = "Checked Out";
                    Console.WriteLine("{0} has been checked out.", mags1.Title);
                    sb.Append(mags1.Title + " (Magazine)");
                    WriteMagFile(mags1, mags2, mags3);
                }
                else
                {
                    Console.WriteLine("That resource is not available.");
                }
            }
            else if (input.Equals(mags2.Title, StringComparison.CurrentCultureIgnoreCase))
            {
                if (mags2.Status == "Available")
                {
                    mags2.Status = "Checked Out";
                    Console.WriteLine("{0} has been checked out.", mags2.Title);
                    sb.Append(mags2.Title + " (Magazine)");
                    WriteMagFile(mags1, mags2, mags3);
                }
                else
                {
                    Console.WriteLine("That resource is not available.");
                }
            }
            else if (input.Equals(mags3.Title, StringComparison.CurrentCultureIgnoreCase))
            {
                if (mags3.Status == "Available")
                {
                    mags3.Status = "Checked Out";
                    Console.WriteLine("{0} has been checked out.", mags3.Title);
                    sb.Append(mags3.Title + " (Magazine)");
                    WriteMagFile(mags1, mags2, mags3);
                }
                else
                {
                    Console.WriteLine("That resource is not available.");
                }
            }
            else
            {
                Console.WriteLine("That resource does not exist.");
            }

            return(sb.ToString());
        }
Ejemplo n.º 3
0
        public void WriteAllResourcesFile(DVD one, DVD two, DVD three, Magazine mag1, Magazine mag2, Magazine mag3, Book b1, Book b2, Book b3)
        {
            StreamWriter writer = new StreamWriter("ResourceList.txt");

            using (writer)
            {
                writer.WriteLine(one.Title + (" (DVD)"));
                writer.WriteLine(two.Title + (" (DVD)"));
                writer.WriteLine(three.Title + (" (DVD)"));
                writer.WriteLine(mag1.Title + (" (Magazine)"));
                writer.WriteLine(mag2.Title + (" (Magazine)"));
                writer.WriteLine(mag3.Title + (" (Magazine)"));
                writer.WriteLine(b1.Title + (" (Book)"));
                writer.WriteLine(b2.Title + (" (Book)"));
                writer.WriteLine(b3.Title + (" (Book)"));
            }

            StreamWriter writing = new StreamWriter("CheckedOutResources.txt");

            using (writing)
            {
                if (one.Status == "Checked Out")
                {
                    writing.WriteLine(one.Title);
                }
                if (two.Status == "Checked Out")
                {
                    writing.WriteLine(two.Title);
                }
                if (three.Status == "Checked Out")
                {
                    writing.WriteLine(three.Title);
                }
                if (mag1.Status == "Checked Out")
                {
                    writing.WriteLine(mag1.Title);
                }
                if (mag2.Status == "Checked Out")
                {
                    writing.WriteLine(mag2.Title);
                }
                if (mag3.Status == "Checked Out")
                {
                    writing.WriteLine(mag3.Title);
                }
                if (b1.Status == "Checked Out")
                {
                    writing.WriteLine(b1.Title);
                }
                if (b2.Status == "Checked Out")
                {
                    writing.WriteLine(b2.Title);
                }
                if (b3.Status == "Checked Out")
                {
                    writing.WriteLine(b3.Title);
                }
            }

            StreamWriter writering = new StreamWriter("AvailableResources.txt");

            using (writering)
            {
                if (one.Status == "Available")
                {
                    writering.WriteLine(one.Title);
                }
                if (two.Status == "Available")
                {
                    writering.WriteLine(two.Title);
                }
                if (three.Status == "Available")
                {
                    writering.WriteLine(three.Title);
                }
                if (mag1.Status == "Available")
                {
                    writering.WriteLine(mag1.Title);
                }
                if (mag2.Status == "Available")
                {
                    writering.WriteLine(mag2.Title);
                }
                if (mag3.Status == "Available")
                {
                    writering.WriteLine(mag3.Title);
                }
                if (b1.Status == "Available")
                {
                    writering.WriteLine(b1.Title);
                }
                if (b2.Status == "Available")
                {
                    writering.WriteLine(b2.Title);
                }
                if (b3.Status == "Available")
                {
                    writering.WriteLine(b3.Title);
                }
            }
        }
Ejemplo n.º 4
0
        public void Menu() //initializes all the classes and handles menu option input
        {
            bool          close    = false;
            List <string> students = ReadStudentFile();

            List <string> dvds = ReadFromFile("DVDList.txt");

            string[] splits = dvds[0].Split('-');
            DVD      dvd1   = new DVD(splits);

            string[] splits2 = dvds[1].Split('-');
            DVD      dvd2    = new DVD(splits2);

            string[] splits3 = dvds[2].Split('-');
            DVD      dvd3    = new DVD(splits3);

            List <string> mags = ReadFromFile("MagazineList.txt");

            string[] msplits = mags[0].Split('-');
            Magazine mags1   = new Magazine(msplits);

            string[] msplits2 = mags[1].Split('-');
            Magazine mags2    = new Magazine(msplits2);

            string[] msplits3 = mags[2].Split('-');
            Magazine mags3    = new Magazine(msplits3);

            List <string> books = ReadFromFile("BookList.txt");

            string[] bsplits = books[0].Split('-');
            Book     book1   = new Book(bsplits);

            string[] bsplits2 = books[1].Split('-');
            Book     book2    = new Book(bsplits2);

            string[] bsplits3 = books[2].Split('-');
            Book     book3    = new Book(bsplits3);

            WriteAllResourcesFile(dvd1, dvd2, dvd3, mags1, mags2, mags3, book1, book2, book3);

            while (close == false)
            {
                Console.Clear();
                PrintMenu();

                int    choice;
                string menuChoice = Console.ReadLine();
                Console.WriteLine();

                bool result = int.TryParse(menuChoice, out choice);

                switch (choice)
                {
                case 1:
                    PrintAllResources();
                    break;

                case 2:
                    //view available resources
                    ReadAvailableResourcesFile();
                    break;

                case 3:
                    //edit resources
                    break;

                case 4:
                    ViewStudentAccount(students);
                    break;

                case 5:
                    PrintAllStudentNames();
                    break;

                case 6:
                    CheckInMenu(students, dvd1, dvd2, dvd3, book1, book2, book3, mags1, mags2, mags3);     //add student accounts, list of resources
                    break;

                case 7:
                    CheckOutMenu(students, dvd1, dvd2, dvd3, book1, book2, book3, mags1, mags2, mags3);
                    break;

                case 8:
                    ClosingImage();
                    close = true;
                    break;

                default:
                    continue;
                }
            }
        }