Unit 1 Project: Movie Collection
In this project, you will create a simple movie collection program. The program will allow you to add movies to a collection, view the movies in the collection, and search for movies by title.
Project Requirements
-
Create a
Movie
class with the following properties:title
: The title of the movieyear
: The year the movie was releasedgenre
: The genre of the movierating
: The rating of the movie TheMovie
class should have a primary constructor that initializes these properties.- The properties should be read-only (use
val
instead ofvar
). - The
rating
property should be aDouble
value between0.0
and10.0
. - The
year
property should be anInt
value representing the release year. - The
genre
property should be aString
value representing the genre of the movie. - The
title
property should be aString
value representing the title of the movie. - A
display
method that returns a string representation of the movie in the format:title (year) - genre - rating
.
-
Create a
MovieCollection
class to manage a collection of movies. TheMovieCollection
class should allow you to:- Add a movie to the collection.
- View all movies in the collection.
- Search for a movie by title.
- Remove a movie from the collection by title.
- Calculate the average rating of all movies in the collection.
- Calculate the number of movies in the collection.
- Clear the collection (remove all movies).
-
Create a
main
function to test yourMovieCollection
class. In themain
function, create an instance of theMovieCollection
class and test the functionality of adding movies, viewing movies, searching for movies, removing movies, calculating the average rating, calculating the number of movies, and clearing the collection.
Obviously this isn't strictly "graded" but you should be able to demonstrate the functionality of your program to your software leads, as well as an understanding of the basic concepts of Kotlin.
It is recommended to use GitHub for this project, as you will need to submit it using github.
Once you have completed the project, send a message on Slack to your software leads with a link to the repository containing your project, so we can review your code.