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
Movieclass 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 TheMovieclass should have a primary constructor that initializes these properties.- The properties should be read-only (use
valinstead ofvar). - The
ratingproperty should be aDoublevalue between0.0and10.0. - The
yearproperty should be anIntvalue representing the release year. - The
genreproperty should be aStringvalue representing the genre of the movie. - The
titleproperty should be aStringvalue representing the title of the movie. - A
displaymethod that returns a string representation of the movie in the format:title (year) - genre - rating.
-
Create a
MovieCollectionclass to manage a collection of movies. TheMovieCollectionclass 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
mainfunction to test yourMovieCollectionclass. In themainfunction, create an instance of theMovieCollectionclass 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.