commit 368e2a271c406d5a2a682df83487d5678e5861e2 Author: Jocelyn Date: Mon Jun 22 12:21:36 2026 -0300 Done? diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..30cf57e --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/MovieRental.iml b/.idea/MovieRental.iml new file mode 100644 index 0000000..16d63dc --- /dev/null +++ b/.idea/MovieRental.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d0e46af --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..767f38f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..4187a4c --- /dev/null +++ b/main.py @@ -0,0 +1,10 @@ +from media import * +from movie import * + +media1 = Media("Star Wars", 1977) +media2 = Movie("Drive", 2011, "R", 79) +media3 = Movie("Dune", 2011, "R", 81) + +media1.print_details() +media2.print_details() +media3.print_details() \ No newline at end of file diff --git a/media.py b/media.py new file mode 100644 index 0000000..b5c07ee --- /dev/null +++ b/media.py @@ -0,0 +1,11 @@ +from dataclasses import dataclass + +@dataclass +class Media: + def __init__(self, title, year): + self.year = year + self.title = title + + + def print_details(self): + print(f"Media: {self.title}, {self.year}") \ No newline at end of file diff --git a/movie.py b/movie.py new file mode 100644 index 0000000..956a709 --- /dev/null +++ b/movie.py @@ -0,0 +1,47 @@ +import string +from dataclasses import dataclass +from media import * + + +class Movie(Media): + def __init__(self, title, year, parental_rating, rating): + self.parental_rating = parental_rating + self.rating = rating + + super().__init__(title, year) + + def movie_ratings(self, title, year, parental_rating, rating, imdb_rating): + self.title = title + self.year = year + self.parental_rating = parental_rating + self.rating = imdb_rating * 10 + + def __eq__(self, obj): + return (isinstance(obj, Movie) and + self.title == obj.title and + self.year == obj.year and + self.parental_rating == obj.parental_rating and + self.rating == obj.rating) + + def compare_to(self, other): + if other is None: + return 1 + elif self.rating > other.rating: + return 1 + elif self.rating < other.rating: + return -1 + else: + return 0 + + # Here if I didn't use total_ordering, I would need to complete the logic. + # I think it will work exactly as your CompareTo logic. + + def __hash__(self): + return hash((self.title, self.year, self.parental_rating, self.rating)) + + def __str__(self): + return f"Movie: {self.title}, {self.year}, Parental Rating: {self.parental_rating}, IMDB Rating: {round(self.rating / 10, 1)}" + + def print_details(self): + print(f"Movie: {self.title}, {self.year}, Parental Rating: {self.parental_rating}, IMDB Rating: {round(self.rating / 10, 1)}") +