Esempio n. 1
0
 def test_dvd_class_method(self):
     dvd = DVD.from_date(1, "A", "16.10.1997", 18)
     self.assertEqual(dvd.name, "A")
     self.assertEqual(dvd.id, 1)
     self.assertEqual(dvd.creation_month, "October")
     self.assertEqual(dvd.creation_year, 1997)
     self.assertEqual(dvd.age_restriction, 18)
     self.assertEqual(dvd.is_rented, False)
Esempio n. 2
0
    def __init__(self, name: str, age: int, id: int):
        self.name = name
        self.age = age
        self.id = id
        self.rented_dvds = []

    def __repr__(self):
        return f"{self.id}: {self.name} of age {self.age} has {len(self.rented_dvds)} " \
               f"rented DVD's ({', '.join([dvd.name for dvd in self.rented_dvds])})"


c1 = Customer("John", 16, 1)
c2 = Customer("Anna", 55, 2)

d1 = DVD("Black Widow", 1, 2020, "April", 18)
d2 = DVD.from_date(2, "The Croods 2", "23.12.2020", 3)

movie_world = MovieWorld("The Best Movie Shop")

movie_world.add_customer(c1)
movie_world.add_customer(c2)

movie_world.add_dvd(d1)
movie_world.add_dvd(d2)

print(movie_world.rent_dvd(1, 1))
print(movie_world.rent_dvd(2, 1))
print(movie_world.rent_dvd(1, 2))

print(movie_world)
Esempio n. 3
0
 def test_dvd_repr(self):
     dvd = DVD.from_date(1, "A", "16.10.1997", 18)
     self.assertEqual(
         repr(dvd),
         "1: A (October 1997) has age restriction 18. Status: not rented")
Esempio n. 4
0
from project.customer import Customer
from project.dvd import DVD
from project.movie_world import MovieWorld

customer = Customer('Atanas', 18, 123)
dvd = DVD('CONG: In the Wild', 555, 1998, 'August', 18)
dvd2 = DVD.from_date(777, 'CHE', '12.09.1988', 18)
# dvd.is_rented = True

movie_world = MovieWorld("Gaco")
movie_world.add_customer(customer)
movie_world.add_dvd(dvd)
movie_world.add_dvd(dvd2)

print(movie_world.rent_dvd(123, 555))
print(movie_world.rent_dvd(123, 555))
print(movie_world.return_dvd(123, 555))
print(movie_world.return_dvd(123, 555))
print(movie_world.rent_dvd(123, 777))

print(movie_world)