self.title = title        self.director = director        self.producer = producer        self.release_date = release_date        self.duration = duration        self.dvd_id = dvd_id

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

class dvd:
 

   def __init__(self, title, director, producer, release_date, duration, dvd_id):

 

       self.title = title

       self.director = director

       self.producer = producer

       self.release_date = release_date

       self.duration = duration

       self.dvd_id = dvd_id

 

   def get_title(self):

 

       return self.title

 

   def get_director(self):

 

       return self.director

 

   def get_producer(self):

 

       return self.producer

 

   def get_release_date(self):

 

       return self.release_date

 

   def get_duration(self):

 

       return self.duration

 

   def get_dvd_id(self):

 

       return self.dvd_id

 

 

class customer:

 

   def __init__(self, name, customer_id):

 

       self.name = name

       self.customer_id = customer_id

 

   def get_name(self):

 

       return self.name

 

   def get_customer_id(self):

 

       return self.customer_id

 

 

class store:

 

   def __init__(self):

 

       self.dvds = []

       self.customers = []

 

   def add_dvd(self, dvd):

 

       self.dvds.append(dvd)

 

   def add_customer(self, customer):

 

       self.customers.append(customer)

 

   def rent_dvd(self, dvd_id, customer_id):

 

       for dvd in self.dvds:

           if dvd.get_dvd_id() == dvd_id:

               for customer in self.customers:

                   if customer.get_customer_id() == customer_id:

                       customer.dvds.append(dvd)

                       self.dvds.remove(dvd)

 

   def return_dvd(self, dvd_id, customer_id):

 

       for customer in self.customers:

           if customer.get_customer_id() == customer_id:

               for dvd in customer.dvds:

                   if dvd.get_dvd_id() == dvd_id:

                       self.dvds.append(dvd)

                       customer.dvds.remove(dvd)

 

   def get_dvd(self, dvd_id):

 

       for dvd in self.dvds:

           if dvd.get_dvd_id() == dvd_id:

               return dvd

 

   def get_customer(self, customer_id):

 

       for customer in self.customers:

           if customer.get_customer_id() == customer_id:

               return customer

 

   def get_dvds(self):

 

       return self.dvds

 

   def get_customers(self):

 

       return self.customers

 

   def get_dvds_for_customer(self, customer_id):

 

       for customer in self.customers:

           if customer.get_customer_id() == customer_id:

               return customer.dvds

 

 

# main

 

store = store()

 

dvd1 = dvd("The Godfather", "Francis Ford Coppola", "Albert S. Ruddy", 1972, 175, 1)

dvd2 = dvd("The Shawshank Redemption", "Frank Darabont", "Niki Marvin", 1994, 142, 2)

dvd3 = dvd("Pulp Fiction", "Quentin Tarantino", "Lawrence Bender", 1994, 154, 3)

 

store.add_dvd(dvd1)

store.add_dvd(dvd2)

store.add_dvd(dvd3)

 

customer1 = customer("John Smith", 1)

customer2 = customer("Mary Johnson", 2)

customer3 = customer("Mike Williams", 3)

 

store.add_customer(customer1)

store.add_customer(customer2)

store.add_customer(customer3)

 

store.rent_dvd(1, 1)

store.rent_dvd(2, 1)

store.rent_dvd(3, 2)

store.rent_dvd(3, 3)

store.return_dvd(2, 1)

 

print(store.get_dvd(1))

print(store.get_dvd(2))

print(store.get_dvd(3))

 

print(store.get_customer(1))

print(store.get_customer(2))

print(store.get_customer(3))

 

print(store.get_dvds())

print(store.get_customers())

print(store.get_dvds_for_customer(1))

print(store.get_dvds_for_customer(2))

print(store.get_dvds_for_customer(3))

 

Attribute Error: 'customer' object has no attribute 'dvds'

Eliminate This Attribute Error.

 

def __init__(self, name, customer_id):
self.name = name
self.dvds = []
self.customer_id = customer_id
Transcribed Image Text:def __init__(self, name, customer_id): self.name = name self.dvds = [] self.customer_id = customer_id
Expert Solution
steps

Step by step

Solved in 4 steps with 6 images

Blurred answer
Knowledge Booster
Database connectivity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education