C# .NET Application Book Publication and Display as per requirement

profilenihil.khagram
ass2.pdf

SCIT, University of Wollongong ISIT114/MTS9114 Object Oriented Programming

Spring 2014

Assignment 2 (7%) (Due in your assigned lab, Week 5)

Objectives

• Design and implement a simple inheritance hierarchy.

• Override both library and user-defined methods.

• Work with lists of polymorphic objects.

• Work with predefined objects.

Preliminary

On the following page is a detailed listing of a single novel available in different formats. While they are all publications, we can categorise them into two main types: books and audiobooks.

Examine the example data and design the attributes belonging to the parent class Publication, with two child classes Book and AudioBook. To do this, you should consider which items are audio books and which items are books. Then make a list of all the attributes, and place the common attributes in the parent class and the remaining attributes in the appropriate child class.

1

Tracker by C. J. Cherryh $14.90

Hardcover: 416 pages

Genre: Science Fiction

Publisher: DAW Books

Published: 7/04/2015

ISBN-13: 9780756409098

Tracker by C. J. Cherryh $14.99

eBook: 416 pages

Genre: Science Fiction

Publisher: DAW Books

Published: 7/04/2015

ISBN-13: 9780698146253

Tracker by C. J. Cherryh, Narrated by Daniel Thomas May $25.95

Format: mp3

Play length: 13 hours and 37 minutes

Genre: Science Fiction

Publisher: Audible Studios

Published: 7/04/2015

Tracker by C. J. Cherryh $7.99

Paperback: 416 pages

Genre: Science Fiction

Publisher: DAW Books

Published: 5/04/2016

ISBN-13: 9780756410759

Tracker by C. J. Cherryh, Narrated by Daniel Thomas May $14.99

Format: audioCD

Play length: 13 hours and 37 minutes

Genre: Science Fiction

Publisher: Audible Studios

Published: 27/10/2015

2

Standard

Note: ISIT114 students are only required to complete the standard section to obtain 100% of the marks for the assignment.

1. Define the Publication class and write C# properties for each attribute. (Note: you may use auto- implemented properties and are not required to implement a constructor, but you can if you wish)

2. Override the ToString() method in the Publication class to return a formatted string containing the title, author, and price. For example:

Tracker by C. J. Cherryh $14.90

3. Define a PrintDetails() method in the Publication class to print the remaining lines common to all publications.

4. Define the Book class as inheriting from Publication and write C# properties for each additional attribute. Override the PrintDetails() method to also the lines specific to a Book. Because the important details of a book are the same as those for a publication, you should not need to override the ToString() method.

5. Define the AudioBook class as inheriting from Publication and write C# properties for each addi- tional attribute. Override the PrintDetails() method to also print the lines specific to an AudioBook. Override the ToString() method to include the narrator.

6. Create a single list of Publications, initialised to contain the example data.

7. Loop through each item, printing the string representation of the item followed by its details.

Extension

Note: For MTS9114 students, standard and extension sections are each worth 50% of the marks for the assignment.

8. If you haven’t already. Modify the implementation of the Publication class so that the publication date property is of type DateTime. Ensure that everything still works.

9. Every publication has a publication date. In most cases, the date is in the past, and the publication was “Published” on that date. However, if the date is in the future, the publication has not yet been published, and will become “Available” on that date. Change the PrintDetails() implementation so that the publication date is printed differently depending on whether the publication date is after today or not. You should be able to achieve this by using methods and formatting options available to the DateTime class

Normally, the format should be: Published: 7/04/2015

but if the publication date is in the future, the format should be: Available: Tuesday, 27 October 2015

3

10. Every book has an ISBN. Because the old ISBN format only used 10 digits, they are often printed with a hyphen between the first 3 digits and the remaining 10 digits. Modify the PrintDetails() method to output the ISBN in this format: ISBN-13: 978-0756410759

11. You can determine whether and ISBN is valid by calculating a checksum. For 13-digit ISBNs, this is done by calculating the sum of the 2nd, 4th, 6th, 8th, 10th, and 12th, multiplied by 3 and adding the sum of the remaining 1st, 3rd, 5th, 7th, 9th, 11th, and 13th digits. If the resulting total is divisible by 10, then the ISBN is valid. Write a method in the Book class to check an ISBN13. It should return true if the ISBN13 is valid.

12. Modify the PrintDetails() method of the Book class to print (valid) or (invalid) after the ISBN as appropriate. For example: ISBN-13: 978-0756409098 (valid)

13. Write a comment explaining whether you think it is better to store an ISBN as a long or a string. Explain your answer.

14. Write a method in the Program class which returns a list of all Publications with an invalid ISBN. Write code in main to test this method.

Submission instructions

You must submit your C# code via the eLearning site (Moodle assignment dropbox) once you have been successfully marked in the laboratory. It is this submission that is the official record that you have completed the assessment.

1. Assignments are marked in your assigned lab, you may be required to answer questions, or modify your code.

2. Late submissions will be marked with a 20% deduction for each week late.

3. Submissions more than two weeks late will not be marked, unless an extension has been granted.

4. If you need an extension apply through SOLS, if possible before the assignment deadline.

5. Plagiarism is treated seriously. If we suspect any work is copied, all students involved are likely to receive zero for the entire assignment.

4