-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMedia.java
More file actions
65 lines (57 loc) · 1.74 KB
/
Media.java
File metadata and controls
65 lines (57 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import java.util.*;
/**
* An interface to represent various types of media (movies, books, tv shows, songs, etc.).
*/
public interface Media {
/**
* Gets the title of this media.
*
* @return The title of this media.
*/
public String getTitle();
/**
* Gets all artists associated with this media.
*
* @return A list of artists for this media.
*/
public List<String> getArtists();
/**
* Adds a rating to this media.
*
* @param score The score for the new rating. Should be non-negative.
*/
public void addRating(int score);
/**
* Gets the number of times this media has been rated.
*
* @return The number of ratings for this media.
*/
public int getNumRatings();
/**
* Gets the average (mean) of all ratings for this media.
*
* @return The average (mean) of all ratings for this media.
* If no ratings exist, returns 0.
*/
public double getAverageRating();
/**
* Gets all of the content contained in this media.
*
* @ returns The content stored in a List of strings. If there is no content, an empty list
*/
public List<String> getContent();
/**
* Produce a readable string representation. of this media
*
* If the media has zero ratings, the format will be:
* "<title> by [<artists>]"
*
* If the media has at least one review, the format will be:
* "<title> by [<artists>]: <average rating> (<num ratings> ratings)"
*
* The average rating displayed will be rounded to at most two decimal places.
*
* @ returns The appropriately formatted string representation
*/
public String toString();
}