Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 51 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ subclasses `Album`, `Movie`, and `Book` need to be created and implemented.

## Creating the Base Class `LibraryItem`

The first class that you will need to create is the `LibraryItem` class. This class will be the base class for the
The first class that you will need to create is the `LibraryItem` class. This class will be the base class for the
`Album`, `Movie`, and `Book` classes, and need to contain the following `protected` fields:

| Property | Type | Description |
|----------|--------|----------------------------------------|
| title | String | The title of the item |
| year | int | The year the item was released |
| author | String | The author of the item (if applicable) |
| Property | Type | Description |
| -------- | ------ | ------------------------------ |
| title | String | The title of the item |
| author | String | The author of the item |
| year | int | The year the item was released |

The `LibraryItem` class should also contain the following methods:

| Method | Arguments | Return Type | Description |
|---------------|---------------------------------------------------|--------------|--------------------------------------------------------|
| `LibraryItem` | `title` (String), `year` (int), `author` (String) | None | Constructor that initializes the fields of the class |
| `toString` | None | String | Returns a string representation of the item |
| `getTitle` | None | String | Returns the title of the item (getter method) |
| `getYear` | None | int | Returns the year the item was released (getter method) |
| `getAuthor` | None | String | Returns the author of the item (getter method) |
| Method | Arguments | Return Type | Description |
| ------------- | ------------------------------------------------- | ----------- | ------------------------------------------------------ |
| `LibraryItem` | `title` (String), `author` (String), `year` (int) | None | Constructor that initializes the fields of the class |
| `toString` | None | String | Returns a string representation of the item |
| `getTitle` | None | String | Returns the title of the item (getter method) |
| `getYear` | None | int | Returns the year the item was released (getter method) |
| `getAuthor` | None | String | Returns the author of the item (getter method) |

For your `toString` method, return a string formatted as follows:

Expand All @@ -40,98 +40,97 @@ Item: <title> by <author> (<year>)

The `Album` class is a subclass of the `LibraryItem` class and should contain the following additiohnal `protected` fields:

| Property | Type | Description |
|------------|---------|-----------------------------------------|
| trackCount | int | The number of tracks on the album |
| Property | Type | Description |
| ---------- | ---- | --------------------------------- |
| trackCount | int | The number of tracks on the album |

You should also include an accessor method for the `trackCount` field:

| Method | Arguments | Return Type | Description |
|-----------------|--------------|-------------|-----------------------------------------------------------|
| `getTrackCount` | None | int | Returns the number of tracks on the album (getter method) |
| Method | Arguments | Return Type | Description |
| --------------- | --------- | ----------- | --------------------------------------------------------- |
| `getTrackCount` | None | int | Returns the number of tracks on the album (getter method) |

You will also need to implement a constructor that accepts the same arguments as the `LibraryItem` constructor, as well as
an additional argument for the `trackCount` field. Remember to call the superclass constructor to initialize the fields of the
an additional argument for the `trackCount` field. Remember to call the superclass constructor to initialize the fields of the
`LibraryItem` class, using the `super` keyword.

Finally, you will need to override the `toString` method to return a string representation of the `Album` object. The string
Finally, you will need to override the `toString` method to return a string representation of the `Album` object. The string

You should override the `toString` method to return a string representation of the `Album` object in the following format:

```
Album: <title> by <author> (<year>) - <trackCount> tracks
```

| Method | Arguments | Return Type | Description |
|-----------------|-----------------------------------------------------------------------|--------------|------------------------------------------------------------|
| `Album` | `title` (String), `year` (int), `author` (String), `trackCount` (int) | None | Constructor that initializes the fields of the class |
| `toString` | None | String | Returns a string representation of the album |

| Method | Arguments | Return Type | Description |
| ---------- | --------------------------------------------------------------------- | ----------- | ---------------------------------------------------- |
| `Album` | `title` (String), `author` (String), `year` (int), `trackCount` (int) | None | Constructor that initializes the fields of the class |
| `toString` | None | String | Returns a string representation of the album |

## Creawting the `Movie` Subclass

The `Movie` class is a subclass of the `LibraryItem` class and should contain the following additional `protected` fields:

| Property | Type | Description |
|-------------------|---------|-----------------------------------------|
| durationInMinutes | int | The duration of the movie in minutes |
| Property | Type | Description |
| ----------------- | ---- | ------------------------------------ |
| durationInMinutes | int | The duration of the movie in minutes |

You should also include an accessor method for the `durationInMinutes` field:

| Method | Arguments | Return Type | Description |
|-------------------------|--------------|-------------|--------------------------------------------------------------|
| `getDurationInMinutes` | None | int | Returns the duration of the movie in minutes (getter method) |
| Method | Arguments | Return Type | Description |
| ---------------------- | --------- | ----------- | ------------------------------------------------------------ |
| `getDurationInMinutes` | None | int | Returns the duration of the movie in minutes (getter method) |

You will also need to implement a constructor that accepts the same arguments as the `LibraryItem` constructor, as well as
an additional argument for the `durationInMinutes` field. Remember to call the superclass constructor to initialize the fields of the
an additional argument for the `durationInMinutes` field. Remember to call the superclass constructor to initialize the fields of the
`LibraryItem` class, using the `super` keyword.

Finally, you will need to override the `toString` method to return a string representation of the `Movie` object. The string
Finally, you will need to override the `toString` method to return a string representation of the `Movie` object. The string

You should override the `toString` method to return a string representation of the `Movie` object in the following format:

```
Movie: <title> by <author> (<year>) - <durationInMinutes> minutes
```

| Method | Arguments | Return Type | Description |
|-----------------|------------------------------------------------------------------------------|--------------|-------------------------------------------------------------|
| `Movie` | `title` (String), `year` (int), `author` (String), `durationInMinutes` (int) | None | Constructor that initializes the fields of the class |
| `toString` | None | String | Returns a string representation of the movie |
| Method | Arguments | Return Type | Description |
| ---------- | ---------------------------------------------------------------------------- | ----------- | ---------------------------------------------------- |
| `Movie` | `title` (String), `author` (String), `year` (int), `durationInMinutes` (int) | None | Constructor that initializes the fields of the class |
| `toString` | None | String | Returns a string representation of the movie |

## Creating the `Book` Subclass

The `Book` class is a subclass of the `LibraryItem` class and should contain the following additional `protected` fields:

| Property | Type | Description |
|------------|---------|-----------------------------------------|
| pageCount | int | The number of pages in the book |
| Property | Type | Description |
| --------- | ---- | ------------------------------- |
| pageCount | int | The number of pages in the book |

You should also include an accessor method for the `pageCount` field:

| Method | Arguments | Return Type | Description |
|-----------------|--------------|-------------|--------------------------------------------------------------|
| `getPageCount` | None | int | Returns the number of pages in the book (getter method) |
| Method | Arguments | Return Type | Description |
| -------------- | --------- | ----------- | ------------------------------------------------------- |
| `getPageCount` | None | int | Returns the number of pages in the book (getter method) |

You will also need to implement a constructor that accepts the same arguments as the `LibraryItem` constructor, as well as
an additional argument for the `pageCount` field. Remember to call the superclass constructor to initialize the fields of the
an additional argument for the `pageCount` field. Remember to call the superclass constructor to initialize the fields of the
`LibraryItem` class, using the `super` keyword.

Finally, you will need to override the `toString` method to return a string representation of the `Book` object. The string
Finally, you will need to override the `toString` method to return a string representation of the `Book` object. The string

You should override the `toString` method to return a string representation of the `Book` object in the following format:

```java
"Book: <title> by <author> (<year>) - <pageCount> pages"
```

| Method | Arguments | Return Type | Description |
|-----------------|-----------------------------------------------------------------------|--------------|------------------------------------------------------------|
| `Book` | `title` (String), `year` (int), `author` (String), `pageCount` (int) | None | Constructor that initializes the fields of the class |
| `toString` | None | String | Returns a string representation of the book |
| Method | Arguments | Return Type | Description |
| ---------- | -------------------------------------------------------------------- | ----------- | ---------------------------------------------------- |
| `Book` | `title` (String), `author` (String), `year` (int), `pageCount` (int) | None | Constructor that initializes the fields of the class |
| `toString` | None | String | Returns a string representation of the book |

In the book class, we are going to add one more method specific to `Book`s only. This method will be called
`readBook`, and will take no arguments and return nothing (`void`). The method should simply print out the following
In the book class, we are going to add one more method specific to `Book`s only. This method will be called
`readBook`, and will take no arguments and return nothing (`void`). The method should simply print out the following
message to the console:

```
Expand Down