Question
Create a Console application with two classes. One class will be the test application where the Main method is located. The other public class will
Create a Console application with two classes. One class will be the test application where the Main method is located. The other public class will be named LibraryBook and will be our initial attempt at representing the books held by a library. At the moment, our book class will be very simple. Each LibaryBook object will keep track of some basic information: the book's title (a String), author (a String), publisher (a String), copyright year (an int), call number (a String), and checked out status (a bool). Later, we may add more capabilities (such who checked out the book and when it is due back at the library) but this is a good start.
The specific public requirements for the LibraryBook class are listed below. You may not change or add to the public interface described here.
-A 5-parameter constructor that accepts the book's title (a String), author (a String), publisher (a String), copyright year (an int), and call number (a String), in this order. When a book is created, it will not be checked out yet. Use the set properties for all relevant fields (except the checked out status which does not have a property) to establish their initial values (instead of directly changing instance variables). No other constructor exists for this class (there is NO parameterless constructor for this class). -A String property named Title with a get and set. No validation need be done on the title. You may use an auto-implemented property. -A String property named Author with a get and set. No validation need be done on the author's name. You may use an auto-implemented property./li> -A String property named Publisher with a get and set. No validation need be done on the publisher. You may use an auto-implemented property. -An int property named CopyrightYear with a get and set. To practice validation, you must provide validation in the set accessor. It must ensure that the copyright year value is non-negative when attempting to set; otherwise, set the copyright year to a default value of 2017. -A String property named CallNumber with a get and set. The library uses the call number to categorize the book (like the Dewey decimal system). No validation need be done on the call number. -You may use an auto-implemented property. -A method named CheckOut() that returns no data (void) and accepts no parameters. This method will change the book's checked out status to reflect that the book has been checked out by a patron. -A method named ReturnToShelf() that returns no data (void) and accepts no parameters. This method will change the book's checked out status to reflect that the book has been returned by a patron and is no longer checked out. -A method named IsCheckedOut() that returns a bool and accepts no parameters. This method will return a true value when the book is currently checked out and a false value when the book is not out. Hint: if you use a bool field to keep track of the checked out status, this method can simply return its value.
-A method named ToString() that returns a String and accepts no parameters. Remember, you must also use keyword override when defining a ToString method. This method will create a formatted string that has the book's title, author, publisher, copyright year, call number, and checked out status each on a separate line. Precede each item with an identifying label. You may use string interpolation to create the formatted text that the method will return. Instead of concatenating the string literal " " to add a newline to the string, use the string constant Environment.NewLine instead. Note well, theToString method just builds and returns a string. It does no output of its own. That is up to clientclasses to perform, as the output may be directed to the console or a GUI or a web page. See thePayrollSystem example from class for an example of how ToString() should be written.
In addition to the LibraryBook class, you will need to write a simple Console application to test your books. In your other class file (where the Main method is located), your simple test program must do the following:
-Create at least 5 LibraryBook objects (you may hard code your test data) and store them in an array. -Using a method, print out each object's original data to the Console. -Next, for each book, use the appropriate properties and methods to change either the book's publisher or call number or check out the book - you must check out at least 2 books. These changes can be hard coded (not in a loop). -Again, using a method, print out each object's new data to the console. -Call the appropriate method to return each book that was checked out. -Finally, print each book's data to the console (using a method) one last time.
Since you are printing each book's data to the console several times, you must write a method to accomplish this task in your test application program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started