private FileStream input; //Stream for reading from a file // Precondition: None // Postcondition: The form's GUI is prepared for display. A few test items and patrons // are added to the library public Prog2Form() { InitializeComponent(); _lib = new Library(); // Create the library // Insert test data - Magic numbers allowed here _lib.AddLibraryBook("The Wright Guide to C#", "UofL Press", 2010, 14, "ZZ25 3G", "Andrew Wright"); _lib.AddLibraryBook("Harriet Pooter", "Stealer Books", 2000, 21, "AB73 ZF", "IP Thief"); _lib.AddLibraryMovie("Andrew's Super-Duper Movie", "UofL Movies", 2011, 7, "MM33 2D", 92.5, "Andrew L. Wright", LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.PG); _lib.AddLibraryMovie("Pirates of the Carribean: The Curse of C#", "Disney Programming", 2012, 10, "MO93 4S", 122.5, "Steven Stealberg", LibraryMediaItem.MediaType.DVD, LibraryMovie.MPAARatings.G); _lib.AddLibraryMusic("C# - The Album", "UofL Music", 2014, 14, "CD44 4Z", 84.3, "Dr. A", LibraryMediaItem.MediaType.CD, 10); _lib.AddLibraryMusic("The Sounds of Programming", "Soundproof Music", 1996, 21, "VI64 1Z", 65.0, "Cee Sharpe", LibraryMediaItem.MediaType.VINYL, 12); _lib.AddLibraryJournal("Journal of C# Goodness", "UofL Journals", 2017, 14, "JJ12 7M", 1, 2, "Information Systems", "Andrew Wright"); _lib.AddLibraryJournal("Journal of VB Goodness", "UofL Journals", 2008, 14, "JJ34 3F", 8, 4, "Information Systems", "Alexander Williams"); _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2019, 14, "MA53 9A", 16, 7); _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2019, 14, "MA53 9B", 16, 8); _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2019, 14, "MA53 9C", 16, 9); _lib.AddLibraryMagazine(" VB Magazine ", " UofL Mags ", 2018, 14, "MA21 5V", 1, 1); // Add 5 Patrons _lib.AddPatron("Ima Reader", "12345"); _lib.AddPatron("Jane Doe", "11223"); _lib.AddPatron(" John Smith ", " 654321 "); _lib.AddPatron("James T. Kirk", "98765"); _lib.AddPatron("Jean-Luc Picard", "33456"); }
DialogResult result; // Holds the results of the dialog box // Precondition: None // Postcondition: GUI is initialized and items are added public Program2Form() { InitializeComponent(); _lib = new Library(); //Creates Library //Adds Test Data _lib.AddLibraryBook("How to Read", "Book Inc.", 1990, 14, "000015683", "John Fisher"); _lib.AddLibraryBook("How to do Things", "Publisher Inc.", 1995, 14, "000015615", "Bill Bo Baggings"); _lib.AddLibraryJournal("New Math Theories", "Publisher Inc.", 1500, 18, "000012348", 1, 1, "Math Stuff", "Dukey"); _lib.AddLibraryJournal("Revolutionary Sciencey Stuff", "Publisher Corp", 1904, 21, "000015846", 1, 3, "Science Stuff", "Dr. Grizzwald"); _lib.AddLibraryMagazine("The Subscription", "Magazines Corp", 2050, 7, "000098761", 1, 2); _lib.AddLibraryMagazine("The Subscription", "Magazines Corp", 2051, 7, "000098762", 2, 9); _lib.AddLibraryMovie("The Revenge of Count Walter", "Koon Pictures Inc", 2024, 4, "000012845", 240, "Moose Meat the Third", LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.PG13); _lib.AddLibraryMovie("Black Wasp", "Cynical Juice Box Inc", 2019, 5, "000098514", 180, "Mouse Fish, the Second", LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.R); _lib.AddLibraryMusic("Squash Those Mushrooms", "Music Inc", 2020, 6, "000063541", 51, "Stephan Smith", LibraryMediaItem.MediaType.VINYL, 15); _lib.AddLibraryMusic("Seven In and 4 out", "Loud & Right Company", 2025, 5, "000065482", 60, "7 Snails", LibraryMediaItem.MediaType.SACD, 16); _lib.AddPatron("Billy Bo", "12345"); _lib.AddPatron("Milly Bo", "12346"); _lib.AddPatron("Sally Bo", "12347"); _lib.AddPatron("Silly Bo", "12348"); _lib.AddPatron("Gilly Bo", "12349"); }
private Library _lib; //The Library Object //Precondition: None //Postcondition: Books and Patrons will be displayed in the GUI public Program2() { //Precondition: none //Postcondition: The Program2 Form GUI is initialized InitializeComponent(); _lib = new Library(); //Insert Test Data _lib.AddLibraryBook("The Hills Have Eyes", "UofL Press", 2010, 20, "44RTW", "Dr.Wright"); _lib.AddLibraryBook("To Kill a Mockingbird", "NY Press", 1998, 20, "46RYW", "Moll Happerns"); _lib.AddLibraryMovie("The Color Purple", "Movies Press", 1987, 21, "TT432", 1.23, "Logan Jones", LibraryMediaItem.MediaType.DVD, LibraryMovie.MPAARatings.PG13); _lib.AddLibraryMovie("101 Dalmations", "Kids Movies Press", 1956, 21, "HE321", 2.15, "Jessie James", LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.G); _lib.AddLibraryJournal("Journal of Teen Fashion", "Teen Press", 2019, 14, "PPO98", 4, 6, "Fashion", "Jimmy Richards"); _lib.AddLibraryJournal("Journal of Calculus", "Math Press", 2001, 14, "DEO48", 10, 7, "Math", "Caroline Henderson"); _lib.AddLibraryMagazine("Vogue", "Fashion Press", 2013, 20, "IU74W", 3, 12); _lib.AddLibraryMagazine("NascarRaces", "Cars Press", 2004, 20, "FG487", 5, 7); _lib.AddLibraryMusic("The Sound of Music", "Broadway Classics", 1996, 14, "890TR", 4.67, "Various Artists", LibraryMediaItem.MediaType.CD, 4); _lib.AddLibraryMusic("The Story of My Life", "Music Producers Inc.", 2007, 14, "CCS23", 1.55, "One Direction", LibraryMediaItem.MediaType.CD, 12); //Add 5 Patrons _lib.AddPatron("Emily Robertson", "987EE"); _lib.AddPatron("Molly Baldock", "PP901"); _lib.AddPatron("Jessie Hehn", "87TRE"); _lib.AddPatron("Akansha Gupta", "3WQ12"); _lib.AddPatron("Maddie Bloemer", "54RFC1"); }
DialogResult result; // holds dialog result public MainForm() { InitializeComponent(); _lib = new Library(); // creates the library //Adding library items _lib.AddLibraryBook("The Wright Guide to C#", "UofL Press", 2010, 14, "ZZ25 3G", "Andrew Wright"); _lib.AddLibraryBook("Harry Potter", " Bloomsbury Publishing ", 1997, 14, "ZZ25 3G", " J. K. Rowling"); //Adding 2 two LibraryMovie objects to the list _lib.AddLibraryMovie(" Andrew's Super-Duper Movie ", " UofL Movies ", 2019, 7, "MM33 2D", 92.5, " Andrew L. Wright ", LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.PG); // Trims? _lib.AddLibraryMovie(" Frozen 2 ", " Disney ", 2019, 7, "MM33 2D", 92.5, " Jennifer Lee ", LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.PG); //Adding 2 two LibraryMusic objects to the list _lib.AddLibraryMusic("C# - The Album", "UofL Music", 2020, 14, "CD44 4Z", 84.3, "Dr. A", LibraryMediaItem.MediaType.CD, 10); _lib.AddLibraryMusic("Lover", "Jack Antonoff", 2019, 14, "CD44 4Z", 84.3, "Dr. A", LibraryMediaItem.MediaType.CD, 10); //Adding 2 two LibraryJournal objects to the list _lib.AddLibraryJournal("Journal of C# Goodness", "UofL Journals", 2018, 14, "JJ12 7M", 1, 2, "Information Systems", "Andrew Wright"); _lib.AddLibraryJournal("Physics", "UofL Journals", 2018, 14, "JJ12 7M", 1, 2, "Science", "XYZ"); //Adding 2 two LibraryMagazine objects to the list _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2017, 14, "MA53 9A", 16, 7); _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2017, 14, "MA53 9A", 9, 10); // Adding patrons to the patrons list _lib.AddPatron("Ima Reader", "12345"); _lib.AddPatron("Jane Doe", "11223"); _lib.AddPatron(" John Smith ", " 654321 "); // Trims? _lib.AddPatron("Joe John", "12003"); _lib.AddPatron("Jake", "60890"); _lib.AddPatron(" Steve ", " 70623 "); }
private Library lib; // The library #endregion Fields #region Constructors // Precondition: None // Postcondition: The form's GUI is prepared for display. A few test items and patrons // are added to the library public Prog2Form() { InitializeComponent(); lib = new Library(); // Create the library // Insert test data - Magic numbers allowed here lib.AddLibraryBook("The Wright Guide to C#", "UofL Press", 2010, 14, "ZZ225 3G", "Andrew Wright"); lib.AddLibraryBook("Harriet Pooter", "Stealer Books", 2000, 21, "AG773 ZF", "IP Thief"); lib.AddLibraryMovie("Andrew's Super-Duper Movie", "UofL Movies", 2011, 7, "MM33 2D", 92.5, "Andrew L. Wright", LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.PG); lib.AddLibraryMovie("Pirates of the Carribean: The Curse of C#", "Disney Programming", 2011, 10, "MO93 4S", 122.5, "Steven Stealberg", LibraryMediaItem.MediaType.DVD, LibraryMovie.MPAARatings.G); lib.AddLibraryMusic("C# - The Album", "UofL Music", 2011, 14, "CD44 4Z", 84.3, "Dr. A", LibraryMediaItem.MediaType.CD, 10); lib.AddLibraryMusic("The Sounds of Programming", "Soundproof Music", 1996, 21, "VI64 1Z", 65.0, "Cee Sharpe", LibraryMediaItem.MediaType.VINYL, 12); lib.AddLibraryJournal("Journal of C# Goodness", "UofL Journals", 2011, 14, "JJ12 7M", 1, 2, "Information Systems", "Andrew Wright"); lib.AddLibraryJournal("Journal of VB Goodness", "UofL Journals", 2007, 14, "JJ34 3F", 8, 4, "Information Systems", "Alexander Williams"); lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2010, 14, "MA53 9A", 16, 7); lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2010, 14, "MA53 9B", 16, 8); lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2010, 14, "MA53 9C", 16, 9); lib.AddLibraryMagazine("VB Magazine", "UofL Mags", 2011, 14, "MA21 5V", 1, 1); // Add 5 Patrons lib.AddPatron("Ima Reader", "12345"); lib.AddPatron("Jane Doe", "11223"); lib.AddPatron("John Smith", "54321"); lib.AddPatron("James T. Kirk", "98765"); lib.AddPatron("Jean-Luc Picard", "33456"); }
//Precondition: The program executes //Postcondition: The main form is loaded. private void Form1_Load(object sender, EventArgs e) { // Adding library items to the library // Book // Journal // Magazine // Movie // Music newLibrary.AddLibraryBook("The Book", "New York publishers", 2009, 4, "Row 7", "Just Kidding Rowling"); newLibrary.AddLibraryJournal("The Journal", "Some Publisher", 2009, 67, "Top floor", 5, 10, "Library Research", "Papa John"); newLibrary.AddLibraryMagazine("Forbes", "Some New York Publisher", 2016, 100, "Coffee Table", 1, 2); newLibrary.AddLibraryMovie("The Departed", "Stanley Kubrick", 2012, 2, "Movie Cabinet", 2.40, "Martin Scorcese", LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.R); newLibrary.AddLibraryMusic("John Legend", "Good Pubplisher", 2009, 30, "CD Rack", 1.2, "John Legend", LibraryMediaItem.MediaType.CD, 13); newLibrary.AddPatron("Peter", "1234"); // Adding patron to library newLibrary.AddPatron("Pedro", "3456"); // Adding patron to library newLibrary.AddPatron("Petra", "3453"); // Adding patron to library newLibrary.AddPatron("Donald", "6789"); // Adding patron to library newLibrary.AddPatron("Gattis", "2321"); // Adding patron to library newLibrary.AddPatron("Donald Duck", "1203"); // Adding patron to library }
private Library _lib; // The library // Precondition: None // Postcondition: The form's GUI is prepared for display. A few test items and patrons // are added to the library public Prog2Form() { InitializeComponent(); _lib = new Library(); // Create the library // Insert test data - Magic numbers allowed here _lib.AddLibraryBook("The Wright Guide to C#", "UofL Press", 2010, 14, "ZZ25 3G", "Andrew Wright"); _lib.AddLibraryBook("Harriet Pooter", "Stealer Books", 2000, 21, "AB73 ZF", "IP Thief"); _lib.AddLibraryMovie("Andrew's Super-Duper Movie", "UofL Movies", 2011, 7, "MM33 2D", 92.5, "Andrew L. Wright", LibraryMediaItem.MediaType.BLURAY, LibraryMovie.MPAARatings.PG); _lib.AddLibraryMovie("Pirates of the Carribean: The Curse of C#", "Disney Programming", 2012, 10, "MO93 4S", 122.5, "Steven Stealberg", LibraryMediaItem.MediaType.DVD, LibraryMovie.MPAARatings.G); _lib.AddLibraryMusic("C# - The Album", "UofL Music", 2014, 14, "CD44 4Z", 84.3, "Dr. A", LibraryMediaItem.MediaType.CD, 10); _lib.AddLibraryMusic("The Sounds of Programming", "Soundproof Music", 1996, 21, "VI64 1Z", 65.0, "Cee Sharpe", LibraryMediaItem.MediaType.VINYL, 12); _lib.AddLibraryJournal("Journal of C# Goodness", "UofL Journals", 2000, 14, "JJ12 7M", 1, 2, "Information Systems", "Andrew Wright"); _lib.AddLibraryJournal("Journal of VB Goodness", "UofL Journals", 2008, 14, "JJ34 3F", 8, 4, "Information Systems", "Alexander Williams"); _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2016, 14, "MA53 9A", 16, 7); _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2016, 14, "MA53 9B", 16, 8); _lib.AddLibraryMagazine("C# Monthly", "UofL Mags", 2016, 14, "MA53 9C", 16, 9); _lib.AddLibraryMagazine("VB Magazine", "UofL Mags", 2017, 14, "MA21 5V", 1, 1); // Add 5 Patrons _lib.AddPatron("Ima Reader", "12345"); _lib.AddPatron("Jane Doe", "11223"); _lib.AddPatron("John Smith", "54321"); _lib.AddPatron("James T. Kirk", "98765"); _lib.AddPatron("Jean-Luc Picard", "33456"); string NEW = Environment.NewLine; // Constant string holder for new lines Console.WriteLine("Original List" + NEW); foreach (LibraryItem i in _lib.GetItemsList()) // walking thru library { Console.WriteLine(i + NEW); // print } Console.WriteLine("Please press a key to continue..."); Console.ReadLine(); // Sorting by title _lib.GetItemsList().Sort(); Console.WriteLine("Sorted Items" + NEW); foreach (LibraryItem i in _lib.GetItemsList()) { Console.WriteLine(i + NEW); } Console.WriteLine("Please press a key to continue..."); Console.ReadLine(); // Sorting in desc order by copyright year _lib.GetItemsList().Sort(new DescendingCopyRightYear()); Console.WriteLine("Descending Order by Copyright Year" + NEW); foreach (LibraryItem i in _lib.GetItemsList()) { Console.WriteLine(i + NEW); } Console.WriteLine("Please press a key to continue..."); Console.ReadLine(); }