示例#1
0
文件: MainMenu.cs 项目: yankri/Week11
        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);
                }
            }
        }
示例#2
0
文件: DVD.cs 项目: yankri/Week11
        public static string DVDCheckOutResource(DVD dvd1, DVD dvd2, DVD dvd3)
        {
            StringBuilder sb = new StringBuilder();

            Console.Clear();
            Console.WriteLine("{0} - Status: {1}", dvd1.Title, dvd1.Status);
            Console.WriteLine("{0} - Status: {1}", dvd2.Title, dvd2.Status);
            Console.WriteLine("{0} - Status: {1}", dvd3.Title, dvd3.Status);

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

            if (input.Equals(dvd1.Title, StringComparison.CurrentCultureIgnoreCase))
            {
                if (dvd1.Status == "Available")
                {
                    dvd1.Status = "Checked Out";
                    Console.WriteLine("{0} has been checked out.", dvd1.Title);
                    sb.Append(dvd1.Title + " (DVD)");
                    WriteDVDFile(dvd1, dvd2, dvd3);
                }
                else
                {
                    Console.WriteLine("That resource is not available.");
                }
            }
            else if (input.Equals(dvd2.Title, StringComparison.CurrentCultureIgnoreCase))
            {
                if (dvd2.Status == "Available")
                {
                    dvd2.Status = "Checked Out";
                    Console.WriteLine("{0} has been checked out.", dvd2.Title);
                    sb.Append(dvd2.Title + " (DVD)");
                    WriteDVDFile(dvd1, dvd2, dvd3);
                }
                else
                {
                    Console.WriteLine("That resource is not available.");
                }
            }
            else if (input.Equals(dvd3.Title, StringComparison.CurrentCultureIgnoreCase))
            {
                if (dvd3.Status == "Available")
                {
                    dvd3.Status = "Checked Out";
                    Console.WriteLine("{0} has been checked out.", dvd3.Title);
                    sb.Append(dvd3.Title + " (DVD)");
                    WriteDVDFile(dvd1, dvd2, dvd3);
                }
                else
                {
                    Console.WriteLine("That resource is not available.");
                }
            }
            else
            {
                Console.WriteLine("That resource does not exist.");
            }

            return(sb.ToString());
        }
示例#3
0
文件: MainMenu.cs 项目: yankri/Week11
        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;
                }
            }
        }