0% found this document useful (0 votes)
9 views2 pages

Oop Revision Exam

The document outlines a revision for Object-Oriented Programming (OOP) concepts, focusing on two problems: creating a Musician class with attributes and methods for managing albums and awards, and developing a Bank Account Management System with a base class BankAccount and derived classes SavingsAccount and CheckingAccount. The Musician class includes methods for adding and removing albums and awards, while the Bank Account System allows for account creation, money management, and account display functionalities. Both problems emphasize the use of OOP principles to structure the classes and their interactions.

Uploaded by

jojokamara2345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Oop Revision Exam

The document outlines a revision for Object-Oriented Programming (OOP) concepts, focusing on two problems: creating a Musician class with attributes and methods for managing albums and awards, and developing a Bank Account Management System with a base class BankAccount and derived classes SavingsAccount and CheckingAccount. The Musician class includes methods for adding and removing albums and awards, while the Bank Account System allows for account creation, money management, and account display functionalities. Both problems emphasize the use of OOP principles to structure the classes and their interactions.

Uploaded by

jojokamara2345
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

revison

OOP Revision
Problem 1 : Musician Class
A. Data Attributes
Write a class named Musician , which should have the following data attributes:
__name (for the name of the musician).
__instrument (for the instrument the musician plays, e.g., Guitar, Piano, Drums, etc.).
__genre (for the music genre the musician specializes in, e.g., Rock, Jazz, Classical, etc.).
__albums (a list to store the albums released by the musician, initially an empty list).
__awards (a list to store the awards received by the musician, initially an empty list).

**B. Constructor and Accessor Methods **


The Musician class should have the following methods:
1. An __init__ method to initialize all the attributes.
2. set_name , set_instrument , set_genre methods to update the respective attributes.
3. get_name , get_instrument , get_genre methods to retrieve the respective attributes.

C. Albums and Awards Management Methods [8 Marks]


The Musician class should also have the following methods:
1. add_album(album_name, year) : Adds an album along with its release year to the albums list.
2. add_award(award_name, year) : Adds an award along with the year it was won to the awards list.
3. remove_album(album_name) : Removes an album from the list if it exists, with graceful handling for non-
existent albums.
4. remove_award(award_name) : Removes an award from the list if it exists, with graceful handling for non-
existent awards.

D. Additional Functionalities [10 Marks]


1. A class method get_number_of_musicians() to return the total number of Musician objects created.
2. A __str__ method to return a formatted string representation of the musician's details, including their
name, instrument, genre, albums, and awards.
3. A display_information() method that displays the musician’s details, including their name,
instrument, genre, albums, and awards.

Problem 2 : Bank Account Management System


Problem Statement:
Create a Python project to manage bank accounts. The system should allow users to create bank accounts,
Page 1 of 2
revison
deposit money, withdraw money, and transfer money between accounts. Use object-oriented programming
(OOP) principles to define the base class BankAccount and specialized derived classes for specific types of
accounts such as SavingsAccount and CheckingAccount .

Requirements:
1. Base Class: BankAccount (10 Marks)
Define a class called BankAccount with the following attributes:
account_number : A unique identifier for the account.
account_holder : The name of the account holder.
balance : The current balance in the account.
Define the following methods:
deposit(amount) : Adds money to the balance.
withdraw(amount) : Subtracts money from the balance.
get_balance() : Returns the current balance in the account.
transfer(amount, target_account) : Transfers money to another account.
(Hint: Ensure that withdrawal does not exceed the balance.)
2. Derived Classes: SavingsAccount and CheckingAccount (10 Marks)
Define two classes called SavingsAccount and CheckingAccount that inherit from BankAccount :
SavingsAccount :
Adds an attribute interest_rate (default: 0.02) to represent the interest rate.
Overrides the deposit() method to add interest based on the interest_rate
whenever money is deposited.
CheckingAccount :
Adds an attribute overdraft_limit (default: 500) to represent the overdraft limit
allowed.
Overrides the withdraw() method to allow withdrawals beyond the balance, but only if
it does not exceed the overdraft limit.
3. BankSystem Class (10 Marks)
Define a class called BankSystem to manage all bank accounts:
add_account(account) : Adds an account to the system.
get_account(account_number) : Returns the account with the given account number.
display_all_accounts() : Displays the details of all accounts in the system.

created with the evaluation version of Markdown Monster

Page 2 of 2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy