SDA Assignment#1
SDA Assignment#1
Assignment# 1
Group Members: 5
Zain-ul-Abideen 366482
class Video:
def _init_(self, title, rental_price):
self.title = title
self.rental_price = rental_price
class NewReleaseVideo(Video):
def _init_(self, title):
super()._init_(title, 3)
class ChildrensVideo(Video):
def _init_(self, title):
super()._init_(title, 1.5)
class Customer:
def _init_(self, name):
self.name = name
self.rentals = []
def statement(self):
total_amount, frequent_renter_points = 0, 0
result = "Rental Record for " + self.name + "\n"
Explanation:
Modular Approach:
A modular approach to building a program for a video store receipt generator
would involve dividing the program into different components, each of which
handles a specific functionality. Some of the modules that could be included in
such a program are:
Code Refactoring:
Refactoring is the process of improving the design of existing code, without
changing its external behaviour. Here's a refactoring approach for the video store
receipt generator program:
1. Extract methods - identify and extract repeated code into separate methods,
making the code more readable and reusable. In this code, we have used
get_charge(), get_point() in videos.
2. Create and use classes - create classes for the different components of the
program, such as Customer, Video, ChildrenVideos, and
newReleaseVideos. This will promote encapsulation and reduce coupling
between components, making the code easier to maintain and modify.
5. Use design patterns - apply well-known design patterns to improve the overall
structure of the program, such as the Factory pattern for creating objects, or
the Singleton pattern for creating a single instance of a class.
By following these refactoring steps, the video store receipt generator program
can be improved to have a more robust, scalable, and maintainable design.