Page 391 - Computer_Science_F5
P. 391
Computer Science 3. Common techniques
(a) Syntax errors: Correctly read error messages for quick fixes.
(b) Logic and control flow: Ensure program logic aligns with the project’s goals.
(c) Exception handling: Use try-except blocks to manage potential errors, such
FOR ONLINE READING ONLY
as book not available.
try:
user1.checkout_book(book1)
except Exception as e:
print(f”An error occurred: {e}”)
Question: Assume you are the programmer. Design any system relevant to your
environment, that will use the stages for building an application
Chapter Summary
Reflect on what you have learnt from this chapter, summarise and keep it in your
portfolio.
Revision Exercise 5 Account, SavingsAccount, and
CheckingAccount. Implement
1. Create a Java class named “Car” inheritance to create specialized
with attributes such as make, account types and encapsulation
model, and year. Define methods to protect sensitive account
to set and retrieve these attributes. information.
Instantiate multiple Car objects and 4. Write a Java program to demonstrate
display their details. method overloading by creating
2. Implement a Java program to multiple methods with the same
calculate the area of different name but different parameter lists,
shapes (circle, rectangle, triangle) such as calculating the area of a
using methods for each shape. square, rectangle, and circle.
Use abstraction to hide the 5. Create a Java program to model a
implementation details of the area simple library system with classes
calculation. like Book, Author, and Library.
3. Develop a Java application for a Use inheritance to represent
banking system with classes like relationships between different
382
for Advanced Secondary Schools
Computer Science Form 5.indd 382 23/07/2024 12:34

