Build a digital representation of a movie, where a movie has a title and an optional rating between 1 and 5. Also add a way to rate a movie after creation. The rating is specific to a user, but the title is specific to the movie.
Build a watch list of movies.
Functionality:
- Add movies
- Get the next unwatched movie in the list and set that movie as watched
- Display a list of all movies in the list and their watched statuses and ratings
Note: Do not place a package name.
这道题要求设计一个电影与观影清单的小型对象模型:先表示电影对象,包含标题和可选评分;评分支持在创建后再添加,并且评分是按用户维度记录的。随后需要实现一个 watch list,能够持续添加电影、按顺序取出下一部未观看电影并将其标记为已观看,同时还能列出所有电影及其观看状态和评分。解题重点通常在于使用合适的数据结构维护顺序与状态,例如列表或队列来保存电影顺序,再配合映射或对象字段保存 watched 和 rating 信息。