Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a Console application with two classes in separate files. One class will be the test application where the Main method is located. The other

Create a Console application with two classes in separate files. 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. 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 2018. 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 by setting the checked out status instance variable to true. 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 by setting the checked out status instance variable to false. 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. In other words, return the value of the bool checked out status instance variable. 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, the ToString method just builds and returns a string. It does no output of its own. That is up to client classes to perform, as the output may be directed to the console or a GUI or a web page. See the PayrollSystem or Time examples 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. Your method should be void and will accept the array of book objects as its parameter. 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 the method your wrote previously, print out each object's new data to the console by passing the array of book objects again to the method. Call the appropriate method to return each book that was checked out. Finally, print each book's data to the console (using the method you wrote previously) 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. As noted earlier, the method should be void and will accept the array of book objects as its parameter.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

2 The goals and tools of monetary policy.

Answered: 1 week ago