Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Homework 1

CSE 274, Spring 2023

Due Date:  Monday, February 6 at 8 AM- NO LATE ASSIGNMENTS ACCEPTED.  Early submissions are encouraged.  No questions answered after Friday, February 3 at 5 PM.

Competencies being graded- these are skills you should have learned in the prerequisites to this course:

· Ability to read information from a text file and convert into objects

· Ability to write information to a text file about objects in a specific format.

· Ability to create and manipulate an array or ArrayList of objects

· Ability to create and manipulate objects with inheritance

· Ability to do simple text based input and output with a user

· Ability to read and implement coding standards

The Problem:

Create a simple media library catalog of books and videos.  This involves reading in information about each book and video in the library from the given text file. (Format of the file discussed below).  The list of books and videos is to be stored in an array or ArrayList.  A simple text interface will be provided to allow the user to:

· View the list of books and videos

· Delete a book or video

· Add a book or video

· Save changes to the list to a file

· Exit the program.

The books and videos all contain a unique ID number (integer based) and a title.  In addition, the information presented to the user when listing should include whether or not it is a book or video.  Books will also include author information and publisher information.   Videos will also include a director field and a text based format that can have a value of either Digital, DVD, or Blu-Ray

You should create a parent class named Media that contains all the common attributes (title, unique ID, type).  Media should also contain any necessary get/set methods or constructors.  Additionally, you should create two child classes of Media – Book and Video.  They should contain needed additional attributes (author, publisher for book; director, format for video).

Text file format:

The provided text file contains five lines of information for each Media object.

1. Unique ID (String)

2. Title (String) – may contain spaces

3. Type (String)  - value should be either book or video

4. Type specific

a. If type.equalsIgnoreCase(“book”)- this is author (String) may contain spaces

b. If type.equalsIgnoreCase(“video”)- this is director (String ) may contain spaces

5. Type specific

a. For book, this is publisher (String) may contain spaces

b. For video, this is format (String)  - value must equal either Digital, DVD or Blu-Ray

Hints and Suggestions:

1.  The classes Media, Book and Video should only contain the attributes and methods needed to represent these items.  It should not contain methods to read the information from a file.  Book and Video should inherit from Media.

2. Use appropriate exception handling when reading or writing to the text file.  This means try/catch blocks NOT putting a throws IOException at end of method name.

3. I highly recommend using Scanner for text file reading and PrintWriter for text file writing.  Use nextLine() rather than next() method in Scanner to make sure you read the spaces on those String which may have spaces.

4. File handling belongs either in the main method which should be in its own class (not Media, Book or Video) or in a method called from main.

5. User interface should also be in or called from main method.

6. Coding standards are linked in Canvas under Useful Links.  You are expected to follow these standards.  The example provided in Canvas to help you with this homework does follow the coding standards if you need an example.

Grading Criteria (out of 100 points)

Competency

Points

Correctly uses inheritance to create Book/Video classes

10

Correctly reads from text file

15

Correctly creates an array or ArrayList of Media objects

20

Correctly adds new book or video to array or ArrayList

10

Correctly removes book or video from array or ArrayList

10

Correctly saves changed array or ArrayList to the text file

15

Follows coding standards

10